replies_generated.go RawHistoryFolder
1// Code generated by xtgen; DO NOT EDIT.
2package xcmisc
3
4import "encoding/binary"
5
6// GetVersionReply is a zero-copy view over a GetVersion reply; offsets count from reply byte 0.
7// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
8type GetVersionReply struct{ raw []byte }
9
10// ParseGetVersionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
11func ParseGetVersionReply(raw []byte) (GetVersionReply, bool) {
12 if len(raw) < 32 {
13 return GetVersionReply{}, false
14 }
15 r := GetVersionReply{raw: raw}
16 return r, true
17}
18func (r GetVersionReply) Raw() []byte { return r.raw }
19func (r GetVersionReply) ServerMajorVersion() uint16 {
20 return uint16(binary.LittleEndian.Uint16(r.raw[8:]))
21}
22func (r GetVersionReply) ServerMinorVersion() uint16 {
23 return uint16(binary.LittleEndian.Uint16(r.raw[10:]))
24}
25
26// GetXIDRangeReply is a zero-copy view over a GetXIDRange reply; offsets count from reply byte 0.
27// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
28type GetXIDRangeReply struct{ raw []byte }
29
30// ParseGetXIDRangeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
31func ParseGetXIDRangeReply(raw []byte) (GetXIDRangeReply, bool) {
32 if len(raw) < 32 {
33 return GetXIDRangeReply{}, false
34 }
35 r := GetXIDRangeReply{raw: raw}
36 return r, true
37}
38func (r GetXIDRangeReply) Raw() []byte { return r.raw }
39func (r GetXIDRangeReply) StartId() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) }
40func (r GetXIDRangeReply) Count() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) }
41
42// GetXIDListReply is a zero-copy view over a GetXIDList reply; offsets count from reply byte 0.
43// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
44type GetXIDListReply struct{ raw []byte }
45
46// ParseGetXIDListReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
47func ParseGetXIDListReply(raw []byte) (GetXIDListReply, bool) {
48 if len(raw) < 32 {
49 return GetXIDListReply{}, false
50 }
51 r := GetXIDListReply{raw: raw}
52 off := 32
53 {
54 n := int(r.IdsLen())
55 if n < 0 || n > len(r.raw) {
56 return GetXIDListReply{}, false
57 }
58 off += n * 4
59 }
60 if off > len(r.raw) {
61 return GetXIDListReply{}, false
62 }
63 if off > len(r.raw) {
64 return GetXIDListReply{}, false
65 }
66 return r, true
67}
68func (r GetXIDListReply) Raw() []byte { return r.raw }
69func (r GetXIDListReply) IdsLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) }
70func (r GetXIDListReply) Ids() Uint32List {
71 off := 32
72 end := off + (int(r.IdsLen()))*4
73 return Uint32List{b: r.raw[off:end:end]}
74}
75
76// Uint32List is a borrowed view over a wire list of uint32. It shares the lifetime of the bytes it was taken from; copy what you keep.
77type Uint32List struct{ b []byte }
78
79func (l Uint32List) Len() int { return len(l.b) / 4 }
80func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) }