// Code generated by xtgen; DO NOT EDIT. package xcmisc import "encoding/binary" // GetVersionReply is a zero-copy view over a GetVersion reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetVersionReply struct{ raw []byte } // ParseGetVersionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetVersionReply(raw []byte) (GetVersionReply, bool) { if len(raw) < 32 { return GetVersionReply{}, false } r := GetVersionReply{raw: raw} return r, true } func (r GetVersionReply) Raw() []byte { return r.raw } func (r GetVersionReply) ServerMajorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r GetVersionReply) ServerMinorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } // GetXIDRangeReply is a zero-copy view over a GetXIDRange reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetXIDRangeReply struct{ raw []byte } // ParseGetXIDRangeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetXIDRangeReply(raw []byte) (GetXIDRangeReply, bool) { if len(raw) < 32 { return GetXIDRangeReply{}, false } r := GetXIDRangeReply{raw: raw} return r, true } func (r GetXIDRangeReply) Raw() []byte { return r.raw } func (r GetXIDRangeReply) StartId() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetXIDRangeReply) Count() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) } // GetXIDListReply is a zero-copy view over a GetXIDList reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetXIDListReply struct{ raw []byte } // ParseGetXIDListReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetXIDListReply(raw []byte) (GetXIDListReply, bool) { if len(raw) < 32 { return GetXIDListReply{}, false } r := GetXIDListReply{raw: raw} off := 32 { n := int(r.IdsLen()) if n < 0 || n > len(r.raw) { return GetXIDListReply{}, false } off += n * 4 } if off > len(r.raw) { return GetXIDListReply{}, false } if off > len(r.raw) { return GetXIDListReply{}, false } return r, true } func (r GetXIDListReply) Raw() []byte { return r.raw } func (r GetXIDListReply) IdsLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetXIDListReply) Ids() Uint32List { off := 32 end := off + (int(r.IdsLen()))*4 return Uint32List{b: r.raw[off:end:end]} } // 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. type Uint32List struct{ b []byte } func (l Uint32List) Len() int { return len(l.b) / 4 } func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) }