(val any)
| 1246 | var _ InputDecoder = ArrayInput[Input]{} |
| 1247 | |
| 1248 | func (a ArrayInput[I]) DecodeInput(val any) (Input, error) { |
| 1249 | switch x := val.(type) { |
| 1250 | case []any: |
| 1251 | var zero I |
| 1252 | decoder := zero.Decoder() |
| 1253 | |
| 1254 | arr := make(ArrayInput[I], len(x)) |
| 1255 | for i, val := range x { |
| 1256 | elem, err := decoder.DecodeInput(val) |
| 1257 | if err != nil { |
| 1258 | return nil, fmt.Errorf("ArrayInput.New[%d]: %w", i, err) |
| 1259 | } |
| 1260 | arr[i] = elem.(I) // TODO sus |
| 1261 | } |
| 1262 | return arr, nil |
| 1263 | case string: // default |
| 1264 | var vals []any |
| 1265 | dec := json.NewDecoder(strings.NewReader(x)) |
| 1266 | dec.UseNumber() |
| 1267 | if err := dec.Decode(&vals); err != nil { |
| 1268 | return nil, fmt.Errorf("decode %q: %w", x, err) |
| 1269 | } |
| 1270 | return a.DecodeInput(vals) |
| 1271 | default: |
| 1272 | return nil, fmt.Errorf("cannot create ArrayInput from %T", x) |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | func (i ArrayInput[S]) ToLiteral() call.Literal { |
| 1277 | lits := make([]call.Literal, 0, len(i)) |
nothing calls this directly
no test coverage detected