MCPcopy Create free account
hub / github.com/segmentio/encoding / encodeString

Function encodeString

proto/string.go:24–40  ·  view source on GitHub ↗
(b []byte, p unsafe.Pointer, flags flags)

Source from the content-addressed store, hash-verified

22}
23
24func encodeString(b []byte, p unsafe.Pointer, flags flags) (int, error) {
25 if p != nil {
26 if v := *(*string)(p); v != "" || flags.has(wantzero) {
27 n, err := encodeVarint(b, uint64(len(v)))
28 if err != nil {
29 return n, err
30 }
31 c := copy(b[n:], v)
32 n += c
33 if c < len(v) {
34 err = io.ErrShortBuffer
35 }
36 return n, err
37 }
38 }
39 return 0, nil
40}
41
42func decodeString(b []byte, p unsafe.Pointer, _ flags) (int, error) {
43 v, n, err := decodeVarlen(b)

Callers

nothing calls this directly

Calls 2

encodeVarintFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…