github.com/karrick/gorill@v1.10.3/types.go (about)

     1  package gorill
     2  
     3  type opcode byte
     4  
     5  const (
     6  	_read opcode = iota
     7  	_write
     8  	_flush
     9  )
    10  
    11  // rillJob represents a job to perform either a read or write operation to a stream
    12  type rillJob struct {
    13  	op      opcode
    14  	data    []byte
    15  	results chan rillResult
    16  }
    17  
    18  func newRillJob(op opcode, data []byte) *rillJob {
    19  	return &rillJob{op: op, data: data, results: make(chan rillResult, 1)}
    20  }
    21  
    22  // rillResult represents the return values for a read or write operation to a stream
    23  type rillResult struct {
    24  	n   int
    25  	err error
    26  }
    27  
    28  // ErrReadAfterClose is returned if a Read is attempted after Close called.
    29  type ErrReadAfterClose struct{}
    30  
    31  // Error returns a string representation of a ErrReadAfterClose error instance.
    32  func (e ErrReadAfterClose) Error() string {
    33  	return "read on closed reader"
    34  }
    35  
    36  // ErrWriteAfterClose is returned if a Write is attempted after Close called.
    37  type ErrWriteAfterClose struct{}
    38  
    39  // Error returns a string representation of a ErrWriteAfterClose error instance.
    40  func (e ErrWriteAfterClose) Error() string {
    41  	return "write on closed writer"
    42  }