MCPcopy Create free account
hub / github.com/CrowdStrike/csproto / DecodeBool

Method DecodeBool

decoder.go:148–161  ·  view source on GitHub ↗

DecodeBool decodes a boolean value from the stream and returns the value. io.ErrUnexpectedEOF is returned if the operation would read past the end of the data.

()

Source from the content-addressed store, hash-verified

146//
147// io.ErrUnexpectedEOF is returned if the operation would read past the end of the data.
148func (d *Decoder) DecodeBool() (b bool, err error) {
149 if d.offset >= len(d.p) {
150 return false, io.ErrUnexpectedEOF
151 }
152 v, n, err := DecodeVarint(d.p[d.offset:])
153 if err != nil {
154 return false, fmt.Errorf("invalid data at byte %d: %w", d.offset, err)
155 }
156 if n == 0 {
157 return false, fmt.Errorf("invalid data at byte %d: %w", d.offset, ErrInvalidVarintData)
158 }
159 d.offset += n
160 return (v != 0), nil
161}
162
163// DecodeString decodes a length-delimited string from the stream and returns the value.
164//

Callers 15

TestDecoderSeekFunction · 0.95
TestDecodeBoolFunction · 0.95
TestDecoderSkipFunction · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95
UnmarshalMethod · 0.95

Calls 1

DecodeVarintFunction · 0.85

Tested by 4

TestDecoderSeekFunction · 0.76
TestDecodeBoolFunction · 0.76
TestDecoderSkipFunction · 0.76