MCPcopy Create free account
hub / github.com/segmentio/encoding / readUvarint

Method readUvarint

thrift/compact.go:179–202  ·  view source on GitHub ↗
(typ string, max uint64)

Source from the content-addressed store, hash-verified

177}
178
179func (r *compactReader) readUvarint(typ string, max uint64) (uint64, error) {
180 var br io.ByteReader
181
182 switch x := r.Reader().(type) {
183 case *bytes.Buffer:
184 br = x
185 case *bytes.Reader:
186 br = x
187 case *bufio.Reader:
188 br = x
189 case io.ByteReader:
190 br = x
191 default:
192 br = &r.binary
193 }
194
195 u, err := binary.ReadUvarint(br)
196 if err == nil {
197 if u > max {
198 err = fmt.Errorf("%s varint out of range: %d > %d", typ, u, max)
199 }
200 }
201 return u, err
202}
203
204func (r *compactReader) readVarint(typ string, min, max int64) (int64, error) {
205 var br io.ByteReader

Callers 4

ReadLengthMethod · 0.95
ReadMessageMethod · 0.95
ReadListMethod · 0.95
ReadMapMethod · 0.95

Calls 1

ReaderMethod · 0.95

Tested by

no test coverage detected