MCPcopy Create free account
hub / github.com/Merovius/nbd / decode

Method decode

types.go:133–149  ·  view source on GitHub ↗
(e *encoder, l uint32)

Source from the content-addressed store, hash-verified

131}
132
133func (o *optInfo) decode(e *encoder, l uint32) errno {
134 nlen := e.uint32()
135 if l < 6 || nlen > l-6 {
136 return errInvalid
137 }
138 name := make([]byte, nlen)
139 e.read(name)
140 o.name = string(name)
141 nreqs := e.uint16()
142 if (l-nlen-6)%2 != 0 || (l-nlen-6)/2 != uint32(nreqs) {
143 return errInvalid
144 }
145 for ; nreqs > 0; nreqs-- {
146 o.reqs = append(o.reqs, e.uint16())
147 }
148 return 0
149}
150
151func (o *optInfo) encode(e *encoder) {
152 e.writeUint32(uint32(len(o.name)))

Callers

nothing calls this directly

Calls 3

uint32Method · 0.80
readMethod · 0.80
uint16Method · 0.80

Tested by

no test coverage detected