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

Function encodeFuncSliceOf

thrift/encode.go:138–165  ·  view source on GitHub ↗
(t reflect.Type, seen encodeFuncCache)

Source from the content-addressed store, hash-verified

136}
137
138func encodeFuncSliceOf(t reflect.Type, seen encodeFuncCache) encodeFunc {
139 elem := t.Elem()
140 typ := TypeOf(elem)
141 enc := encodeFuncOf(elem, seen)
142
143 return func(w Writer, v reflect.Value, flags flags) error {
144 n := v.Len()
145 if n > math.MaxInt32 {
146 return fmt.Errorf("slice length is too large to be represented in thrift: %d > max(int32)", n)
147 }
148
149 err := w.WriteList(List{
150 Size: int32(n),
151 Type: typ,
152 })
153 if err != nil {
154 return err
155 }
156
157 for i := range n {
158 if err := enc(w, v.Index(i), flags); err != nil {
159 return err
160 }
161 }
162
163 return nil
164 }
165}
166
167func encodeFuncMapOf(t reflect.Type, seen encodeFuncCache) encodeFunc {
168 key, elem := t.Key(), t.Elem()

Callers 1

encodeFuncOfFunction · 0.85

Calls 6

encodeFuncOfFunction · 0.85
IndexMethod · 0.80
TypeOfFunction · 0.70
ElemMethod · 0.65
WriteListMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…