// Code generated by xtgen; DO NOT EDIT. package res import "encoding/binary" // QueryVersionReply is a zero-copy view over a QueryVersion 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 QueryVersionReply struct{ raw []byte } // ParseQueryVersionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryVersionReply(raw []byte) (QueryVersionReply, bool) { if len(raw) < 32 { return QueryVersionReply{}, false } r := QueryVersionReply{raw: raw} return r, true } func (r QueryVersionReply) Raw() []byte { return r.raw } func (r QueryVersionReply) ServerMajor() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r QueryVersionReply) ServerMinor() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } // QueryClientsReply is a zero-copy view over a QueryClients 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 QueryClientsReply struct{ raw []byte } // ParseQueryClientsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryClientsReply(raw []byte) (QueryClientsReply, bool) { if len(raw) < 32 { return QueryClientsReply{}, false } r := QueryClientsReply{raw: raw} off := 32 { n := int(r.NumClients()) if n < 0 || n > len(r.raw) { return QueryClientsReply{}, false } off += n * 8 } if off > len(r.raw) { return QueryClientsReply{}, false } if off > len(r.raw) { return QueryClientsReply{}, false } return r, true } func (r QueryClientsReply) Raw() []byte { return r.raw } func (r QueryClientsReply) NumClients() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryClientsReply) Clients() ClientList { off := 32 end := off + (int(r.NumClients()))*8 return ClientList{b: r.raw[off:end:end]} } // QueryClientResourcesReply is a zero-copy view over a QueryClientResources 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 QueryClientResourcesReply struct{ raw []byte } // ParseQueryClientResourcesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryClientResourcesReply(raw []byte) (QueryClientResourcesReply, bool) { if len(raw) < 32 { return QueryClientResourcesReply{}, false } r := QueryClientResourcesReply{raw: raw} off := 32 { n := int(r.NumTypes()) if n < 0 || n > len(r.raw) { return QueryClientResourcesReply{}, false } off += n * 8 } if off > len(r.raw) { return QueryClientResourcesReply{}, false } if off > len(r.raw) { return QueryClientResourcesReply{}, false } return r, true } func (r QueryClientResourcesReply) Raw() []byte { return r.raw } func (r QueryClientResourcesReply) NumTypes() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryClientResourcesReply) Types() TypeList { off := 32 end := off + (int(r.NumTypes()))*8 return TypeList{b: r.raw[off:end:end]} } // QueryClientPixmapBytesReply is a zero-copy view over a QueryClientPixmapBytes 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 QueryClientPixmapBytesReply struct{ raw []byte } // ParseQueryClientPixmapBytesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryClientPixmapBytesReply(raw []byte) (QueryClientPixmapBytesReply, bool) { if len(raw) < 32 { return QueryClientPixmapBytesReply{}, false } r := QueryClientPixmapBytesReply{raw: raw} return r, true } func (r QueryClientPixmapBytesReply) Raw() []byte { return r.raw } func (r QueryClientPixmapBytesReply) Bytes() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryClientPixmapBytesReply) BytesOverflow() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) } // QueryClientIdsReply is a zero-copy view over a QueryClientIds 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 QueryClientIdsReply struct{ raw []byte } // ParseQueryClientIdsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryClientIdsReply(raw []byte) (QueryClientIdsReply, bool) { if len(raw) < 32 { return QueryClientIdsReply{}, false } r := QueryClientIdsReply{raw: raw} off := 32 { n := int(r.NumIds()) if off > len(r.raw) || n < 0 || n > len(r.raw) { return QueryClientIdsReply{}, false } it := NewClientIdValueIter(r.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return QueryClientIdsReply{}, false } } if off > len(r.raw) { return QueryClientIdsReply{}, false } return r, true } func (r QueryClientIdsReply) Raw() []byte { return r.raw } func (r QueryClientIdsReply) NumIds() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryClientIdsReply) Ids() ClientIdValueIter { off := 32 return NewClientIdValueIter(r.raw[off:], int(r.NumIds())) } // QueryResourceBytesReply is a zero-copy view over a QueryResourceBytes 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 QueryResourceBytesReply struct{ raw []byte } // ParseQueryResourceBytesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryResourceBytesReply(raw []byte) (QueryResourceBytesReply, bool) { if len(raw) < 32 { return QueryResourceBytesReply{}, false } r := QueryResourceBytesReply{raw: raw} off := 32 { n := int(r.NumSizes()) if off > len(r.raw) || n < 0 || n > len(r.raw) { return QueryResourceBytesReply{}, false } it := NewResourceSizeValueIter(r.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return QueryResourceBytesReply{}, false } } if off > len(r.raw) { return QueryResourceBytesReply{}, false } return r, true } func (r QueryResourceBytesReply) Raw() []byte { return r.raw } func (r QueryResourceBytesReply) NumSizes() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryResourceBytesReply) Sizes() ResourceSizeValueIter { off := 32 return NewResourceSizeValueIter(r.raw[off:], int(r.NumSizes())) } // ClientIdValueView is a zero-copy view over one wire-encoded ClientIdValue, yielded by ClientIdValueIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type ClientIdValueView struct{ raw []byte } func (v ClientIdValueView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v ClientIdValueView) Size() int { return len(v.raw) } func sizeClientIdValue(p []byte) int { if len(p) < 12 { return -1 } v := ClientIdValueView{raw: p} _ = v off := 12 { n := (int(v.Length()) / 4) if n < 0 || n > len(v.raw) { return -1 } off += n * 4 } if off > len(v.raw) { return -1 } if off > len(v.raw) { return -1 } return off } func (v ClientIdValueView) Spec() ClientIdSpec { return GetClientIdSpec(v.raw[0:]) } func (v ClientIdValueView) Length() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) } func (v ClientIdValueView) Value() Uint32List { off := 12 end := off + (int(v.Length())/4)*4 return Uint32List{b: v.raw[off:end:end]} } // ClientIdValueIter walks n consecutive ClientIdValue elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type ClientIdValueIter struct { b []byte n int v ClientIdValueView err bool } // NewClientIdValueIter iterates n elements encoded at the start of b. func NewClientIdValueIter(b []byte, n int) ClientIdValueIter { return ClientIdValueIter{b: b, n: n} } func (it *ClientIdValueIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeClientIdValue(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = ClientIdValueView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *ClientIdValueIter) Value() ClientIdValueView { return it.v } func (it *ClientIdValueIter) Err() bool { return it.err } // ResourceSizeValueView is a zero-copy view over one wire-encoded ResourceSizeValue, yielded by ResourceSizeValueIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type ResourceSizeValueView struct{ raw []byte } func (v ResourceSizeValueView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v ResourceSizeValueView) Size() int { return len(v.raw) } func sizeResourceSizeValue(p []byte) int { if len(p) < 24 { return -1 } v := ResourceSizeValueView{raw: p} _ = v off := 24 { n := int(v.NumCrossReferences()) if n < 0 || n > len(v.raw) { return -1 } off += n * 20 } if off > len(v.raw) { return -1 } if off > len(v.raw) { return -1 } return off } func (v ResourceSizeValueView) Size_() ResourceSizeSpec { return GetResourceSizeSpec(v.raw[0:]) } func (v ResourceSizeValueView) NumCrossReferences() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[20:])) } func (v ResourceSizeValueView) CrossReferences() ResourceSizeSpecList { off := 24 end := off + (int(v.NumCrossReferences()))*20 return ResourceSizeSpecList{b: v.raw[off:end:end]} } // ResourceSizeValueIter walks n consecutive ResourceSizeValue elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type ResourceSizeValueIter struct { b []byte n int v ResourceSizeValueView err bool } // NewResourceSizeValueIter iterates n elements encoded at the start of b. func NewResourceSizeValueIter(b []byte, n int) ResourceSizeValueIter { return ResourceSizeValueIter{b: b, n: n} } func (it *ResourceSizeValueIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeResourceSizeValue(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = ResourceSizeValueView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *ResourceSizeValueIter) Value() ResourceSizeValueView { return it.v } func (it *ResourceSizeValueIter) Err() bool { return it.err } // ClientList is a borrowed view over a wire list of Client. It shares the lifetime of the bytes it was taken from; copy what you keep. type ClientList struct{ b []byte } func (l ClientList) Len() int { return len(l.b) / 8 } func (l ClientList) At(i int) Client { return GetClient(l.b[i*8:]) } // ResourceSizeSpecList is a borrowed view over a wire list of ResourceSizeSpec. It shares the lifetime of the bytes it was taken from; copy what you keep. type ResourceSizeSpecList struct{ b []byte } func (l ResourceSizeSpecList) Len() int { return len(l.b) / 20 } func (l ResourceSizeSpecList) At(i int) ResourceSizeSpec { return GetResourceSizeSpec(l.b[i*20:]) } // TypeList is a borrowed view over a wire list of Type. It shares the lifetime of the bytes it was taken from; copy what you keep. type TypeList struct{ b []byte } func (l TypeList) Len() int { return len(l.b) / 8 } func (l TypeList) At(i int) Type { return GetType(l.b[i*8:]) } // 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:])) }