Read reads the next n bytes from last. If last is drained, it tries to read additional data from recv. It blocks if there no additional data available in recv. If Read returns any non-nil error, it will continue to return that error.
(n int)
| 159 | // recv. If Read returns any non-nil error, it will continue to return that |
| 160 | // error. |
| 161 | func (r *recvBufferReader) Read(n int) (buf mem.Buffer, err error) { |
| 162 | if r.err != nil { |
| 163 | return nil, r.err |
| 164 | } |
| 165 | if r.last != nil { |
| 166 | buf = r.last |
| 167 | if r.last.Len() > n { |
| 168 | buf, r.last = mem.SplitUnsafe(buf, n) |
| 169 | } else { |
| 170 | r.last = nil |
| 171 | } |
| 172 | return buf, nil |
| 173 | } |
| 174 | if r.clientStream != nil { |
| 175 | buf, r.err = r.readClient(n) |
| 176 | } else { |
| 177 | buf, r.err = r.read(n) |
| 178 | } |
| 179 | return buf, r.err |
| 180 | } |
| 181 | |
| 182 | func (r *recvBufferReader) readMessageHeader(header []byte) (n int, err error) { |
| 183 | select { |
nothing calls this directly
no test coverage detected