File tree 3 files changed +10
-1
lines changed
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 {
80
80
let v: Vec < RadonTypes > = input. value ( ) . values ( ) . cloned ( ) . collect ( ) ;
81
81
RadonArray :: from ( v)
82
82
}
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
+ }
83
91
84
92
/// This module was introduced for encapsulating the interim legacy logic before WIP-0024 is
85
93
/// introduced, for the sake of maintainability.
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ pub enum RadonOpCodes {
84
84
FloatTruncate = 0x5D ,
85
85
///////////////////////////////////////////////////////////////////////
86
86
// Map operator codes (start at 0x60)
87
- // MapEntries = 0x60,
87
+ MapStringify = 0x60 ,
88
88
MapGetArray = 0x61 ,
89
89
MapGetBoolean = 0x62 ,
90
90
MapGetBytes = 0x63 ,
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ impl Operable for RadonMap {
161
161
}
162
162
( RadonOpCodes :: MapKeys , None ) => Ok ( RadonTypes :: from ( map_operators:: keys ( self ) ) ) ,
163
163
( RadonOpCodes :: MapValues , None ) => Ok ( RadonTypes :: from ( map_operators:: values ( self ) ) ) ,
164
+ ( RadonOpCodes :: MapStringify , None ) => map_operators:: stringify ( self ) . map ( RadonTypes :: from) ,
164
165
( op_code, args) => Err ( RadError :: UnsupportedOperator {
165
166
input_type : RADON_MAP_TYPE_NAME . to_string ( ) ,
166
167
operator : op_code. to_string ( ) ,
You can’t perform that action at this time.
0 commit comments