@@ -141,8 +141,8 @@ pub enum XRPLResult<'a> {
141141 PathFind ( path_find:: PathFind < ' a > ) ,
142142 Random ( random:: Random < ' a > ) ,
143143 RipplePathFind ( ripple_path_find:: RipplePathFind < ' a > ) ,
144- ServerInfo ( server_info:: ServerInfo < ' a > ) ,
145- ServerState ( server_state:: ServerState < ' a > ) ,
144+ ServerInfo ( Box < server_info:: ServerInfo < ' a > > ) ,
145+ ServerState ( Box < server_state:: ServerState < ' a > > ) ,
146146 Submit ( submit:: Submit < ' a > ) ,
147147 SubmitMultisigned ( submit_multisigned:: SubmitMultisigned < ' a > ) ,
148148 TransactionEntry ( transaction_entry:: TransactionEntry < ' a > ) ,
@@ -190,8 +190,16 @@ impl_from_result!(no_ripple_check, NoRippleCheck);
190190impl_from_result ! ( path_find, PathFind ) ;
191191impl_from_result ! ( random, Random ) ;
192192impl_from_result ! ( ripple_path_find, RipplePathFind ) ;
193- impl_from_result ! ( server_info, ServerInfo ) ;
194- impl_from_result ! ( server_state, ServerState ) ;
193+ impl < ' a > From < server_info:: ServerInfo < ' a > > for XRPLResult < ' a > {
194+ fn from ( value : server_info:: ServerInfo < ' a > ) -> Self {
195+ XRPLResult :: ServerInfo ( Box :: new ( value) )
196+ }
197+ }
198+ impl < ' a > From < server_state:: ServerState < ' a > > for XRPLResult < ' a > {
199+ fn from ( value : server_state:: ServerState < ' a > ) -> Self {
200+ XRPLResult :: ServerState ( Box :: new ( value) )
201+ }
202+ }
195203impl_from_result ! ( submit, Submit ) ;
196204impl_from_result ! ( submit_multisigned, SubmitMultisigned ) ;
197205impl_from_result ! ( transaction_entry, TransactionEntry ) ;
@@ -256,8 +264,34 @@ impl_try_from_result!(no_ripple_check, NoRippleCheck, NoRippleCheck);
256264impl_try_from_result ! ( path_find, PathFind , PathFind ) ;
257265impl_try_from_result ! ( random, Random , Random ) ;
258266impl_try_from_result ! ( ripple_path_find, RipplePathFind , RipplePathFind ) ;
259- impl_try_from_result ! ( server_info, ServerInfo , ServerInfo ) ;
260- impl_try_from_result ! ( server_state, ServerState , ServerState ) ;
267+ impl < ' a > TryFrom < XRPLResult < ' a > > for server_info:: ServerInfo < ' a > {
268+ type Error = XRPLModelException ;
269+
270+ fn try_from ( result : XRPLResult < ' a > ) -> XRPLModelResult < Self > {
271+ match result {
272+ XRPLResult :: ServerInfo ( value) => Ok ( * value) ,
273+ res => Err ( XRPLResultException :: UnexpectedResultType (
274+ "ServerInfo" . to_string ( ) ,
275+ res. get_name ( ) ,
276+ )
277+ . into ( ) ) ,
278+ }
279+ }
280+ }
281+ impl < ' a > TryFrom < XRPLResult < ' a > > for server_state:: ServerState < ' a > {
282+ type Error = XRPLModelException ;
283+
284+ fn try_from ( result : XRPLResult < ' a > ) -> XRPLModelResult < Self > {
285+ match result {
286+ XRPLResult :: ServerState ( value) => Ok ( * value) ,
287+ res => Err ( XRPLResultException :: UnexpectedResultType (
288+ "ServerState" . to_string ( ) ,
289+ res. get_name ( ) ,
290+ )
291+ . into ( ) ) ,
292+ }
293+ }
294+ }
261295impl_try_from_result ! ( submit, Submit , Submit ) ;
262296impl_try_from_result ! ( submit_multisigned, SubmitMultisigned , SubmitMultisigned ) ;
263297impl_try_from_result ! ( transaction_entry, TransactionEntry , TransactionEntry ) ;
@@ -407,8 +441,40 @@ impl_try_from_response!(path_find, PathFind, PathFind);
407441impl_try_from_response ! ( ping, Ping , Ping ) ;
408442impl_try_from_response ! ( random, Random , Random ) ;
409443impl_try_from_response ! ( ripple_path_find, RipplePathFind , RipplePathFind ) ;
410- impl_try_from_response ! ( server_info, ServerInfo , ServerInfo ) ;
411- impl_try_from_response ! ( server_state, ServerState , ServerState ) ;
444+ impl < ' a > TryFrom < XRPLResponse < ' a > > for server_info:: ServerInfo < ' a > {
445+ type Error = XRPLModelException ;
446+
447+ fn try_from ( response : XRPLResponse < ' a > ) -> XRPLModelResult < Self > {
448+ match response. result {
449+ Some ( result) => match result {
450+ XRPLResult :: ServerInfo ( value) => Ok ( * value) ,
451+ res => Err ( XRPLResultException :: UnexpectedResultType (
452+ "ServerInfo" . to_string ( ) ,
453+ res. get_name ( ) ,
454+ )
455+ . into ( ) ) ,
456+ } ,
457+ None => Err ( XRPLModelException :: MissingField ( "result" . to_string ( ) ) ) ,
458+ }
459+ }
460+ }
461+ impl < ' a > TryFrom < XRPLResponse < ' a > > for server_state:: ServerState < ' a > {
462+ type Error = XRPLModelException ;
463+
464+ fn try_from ( response : XRPLResponse < ' a > ) -> XRPLModelResult < Self > {
465+ match response. result {
466+ Some ( result) => match result {
467+ XRPLResult :: ServerState ( value) => Ok ( * value) ,
468+ res => Err ( XRPLResultException :: UnexpectedResultType (
469+ "ServerState" . to_string ( ) ,
470+ res. get_name ( ) ,
471+ )
472+ . into ( ) ) ,
473+ } ,
474+ None => Err ( XRPLModelException :: MissingField ( "result" . to_string ( ) ) ) ,
475+ }
476+ }
477+ }
412478impl_try_from_response ! ( submit, Submit , Submit ) ;
413479impl_try_from_response ! ( submit_multisigned, SubmitMultisigned , SubmitMultisigned ) ;
414480impl_try_from_response ! ( transaction_entry, TransactionEntry , TransactionEntry ) ;
0 commit comments