File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,14 @@ pub fn values(input: &RadonMap) -> RadonArray {
8080 let v: Vec < RadonTypes > = input. value ( ) . values ( ) . cloned ( ) . collect ( ) ;
8181 RadonArray :: from ( v)
8282}
83+ pub fn stringify ( input : & RadonMap ) -> Result < RadonString , RadError > {
84+ let json_string = serde_json:: to_string ( & input. value ( ) )
85+ . map_err ( |_| RadError :: Decode {
86+ from : "RadonMap" ,
87+ to : "RadonString"
88+ } ) ?;
89+ Ok ( RadonString :: from ( json_string) )
90+ }
8391
8492/// This module was introduced for encapsulating the interim legacy logic before WIP-0024 is
8593/// introduced, for the sake of maintainability.
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ pub enum RadonOpCodes {
8484 FloatTruncate = 0x5D ,
8585 ///////////////////////////////////////////////////////////////////////
8686 // Map operator codes (start at 0x60)
87- // MapEntries = 0x60,
87+ MapStringify = 0x60 ,
8888 MapGetArray = 0x61 ,
8989 MapGetBoolean = 0x62 ,
9090 MapGetBytes = 0x63 ,
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ impl Operable for RadonMap {
161161 }
162162 ( RadonOpCodes :: MapKeys , None ) => Ok ( RadonTypes :: from ( map_operators:: keys ( self ) ) ) ,
163163 ( RadonOpCodes :: MapValues , None ) => Ok ( RadonTypes :: from ( map_operators:: values ( self ) ) ) ,
164+ ( RadonOpCodes :: MapStringify , None ) => map_operators:: stringify ( self ) . map ( RadonTypes :: from) ,
164165 ( op_code, args) => Err ( RadError :: UnsupportedOperator {
165166 input_type : RADON_MAP_TYPE_NAME . to_string ( ) ,
166167 operator : op_code. to_string ( ) ,
You can’t perform that action at this time.
0 commit comments