MCPcopy Create free account
hub / github.com/aws/smithy-go / encodeArg

Function encodeArg

encoding/cbor/encode.go:155–177  ·  view source on GitHub ↗
(t majorType, arg I, p []byte)

Source from the content-addressed store, hash-verified

153}
154
155func encodeArg[I int | uint64](t majorType, arg I, p []byte) int {
156 aarg := uint64(arg)
157 if aarg < 24 {
158 p[0] = byte(t)<<5 | byte(aarg)
159 return 1
160 } else if aarg < 0x100 {
161 p[0] = compose(t, minorArg1)
162 p[1] = byte(aarg)
163 return 2
164 } else if aarg < 0x10000 {
165 p[0] = compose(t, minorArg2)
166 binary.BigEndian.PutUint16(p[1:], uint16(aarg))
167 return 3
168 } else if aarg < 0x100000000 {
169 p[0] = compose(t, minorArg4)
170 binary.BigEndian.PutUint32(p[1:], uint32(aarg))
171 return 5
172 }
173
174 p[0] = compose(t, minorArg8)
175 binary.BigEndian.PutUint64(p[1:], uint64(aarg))
176 return 9
177}
178
179// EncodeRaw encodes opaque CBOR data.
180//

Callers 7

encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85

Calls 1

composeFunction · 0.85

Tested by

no test coverage detected