github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/stdio/types.go (about) 1 package stdio 2 3 import ( 4 "context" 5 "sort" 6 7 "github.com/lmorg/murex/config" 8 ) 9 10 // readArray is where custom data formats can define how to iterate through arrays (eg `foreach`). 11 // This should only be read from by stream.Io interfaces and written to inside an init() function. 12 var readArray = make(map[string]func(ctx context.Context, read Io, callback func([]byte)) error) 13 14 // readArrayWithType is where custom data formats can define how to iterate through arrays (eg `foreach`). 15 // This should only be read from by stream.Io interfaces and written to inside an init() function. 16 var readArrayWithType = make(map[string]func(ctx context.Context, read Io, callback func(interface{}, string)) error) 17 18 // ReadMap is where custom data formats can define how to iterate through structured data (eg `formap`). 19 // This should only be read from by stream.Io interfaces and written to inside an init() function. 20 var readMap = make(map[string]func(read Io, config *config.Config, callback func(*Map)) error) 21 22 // WriteArray is where custom data formats can define how to do buffered writes 23 var writeArray = make(map[string]func(read Io) (ArrayWriter, error)) 24 25 // DumpReadArray returns an array of compiled builtins supporting deserialization as an Array 26 func DumpReadArray() (dump []string) { 27 for name := range readArray { 28 dump = append(dump, name) 29 } 30 sort.Strings(dump) 31 return 32 } 33 34 // DumpReadArrayWithType returns an array of compiled builtins supporting deserialization as an ArrayWithType 35 func DumpReadArrayWithType() (dump []string) { 36 for name := range readArrayWithType { 37 dump = append(dump, name) 38 } 39 sort.Strings(dump) 40 return 41 } 42 43 // DumpMap returns an array of compiled builtins supporting deserialization as a key/value map (or hash) 44 func DumpMap() (dump []string) { 45 for name := range readMap { 46 dump = append(dump, name) 47 } 48 sort.Strings(dump) 49 return 50 } 51 52 // DumpWriteArray returns an array of compiled builtins supporting serialization as an Array 53 func DumpWriteArray() (dump []string) { 54 for name := range writeArray { 55 dump = append(dump, name) 56 } 57 sort.Strings(dump) 58 return 59 }