MCPcopy
hub / github.com/tinylib/msgp / NextType

Function NextType

msgp/read_bytes.go:18–43  ·  view source on GitHub ↗

NextType returns the type of the next object in the slice. If the length of the input is zero, it returns [InvalidType].

(b []byte)

Source from the content-addressed store, hash-verified

16// of the input is zero, it returns
17// [InvalidType].
18func NextType(b []byte) Type {
19 if len(b) == 0 {
20 return InvalidType
21 }
22 spec := getBytespec(b[0])
23 t := spec.typ
24 if t == ExtensionType && len(b) > int(spec.size) {
25 var tp int8
26 if spec.extra == constsize {
27 tp = int8(b[1])
28 } else {
29 tp = int8(b[spec.size-1])
30 }
31 switch tp {
32 case TimeExtension, MsgTimeExtension:
33 return TimeType
34 case Complex128Extension:
35 return Complex128Type
36 case Complex64Extension:
37 return Complex64Type
38 default:
39 return ExtensionType
40 }
41 }
42 return t
43}
44
45// IsNil returns true if len(b)>0 and
46// the leading byte is a 'nil' MessagePack

Callers 4

WriteMethod · 0.92
WriteMethod · 0.92
UnmarshalMsgMethod · 0.85
readIntfBytesDepthFunction · 0.85

Calls 1

getBytespecFunction · 0.70

Tested by 2

WriteMethod · 0.74
WriteMethod · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…