@@ -142,8 +142,8 @@ pub enum XRPLResult<'a> {
142142 PathFind ( path_find:: PathFind < ' a > ) ,
143143 Random ( random:: Random < ' a > ) ,
144144 RipplePathFind ( ripple_path_find:: RipplePathFind < ' a > ) ,
145- ServerInfo ( server_info:: ServerInfo < ' a > ) ,
146- ServerState ( server_state:: ServerState < ' a > ) ,
145+ ServerInfo ( Box < server_info:: ServerInfo < ' a > > ) ,
146+ ServerState ( Box < server_state:: ServerState < ' a > > ) ,
147147 Submit ( submit:: Submit < ' a > ) ,
148148 SubmitMultisigned ( submit_multisigned:: SubmitMultisigned < ' a > ) ,
149149 TransactionEntry ( transaction_entry:: TransactionEntry < ' a > ) ,
@@ -194,8 +194,16 @@ impl_from_result!(no_ripple_check, NoRippleCheck);
194194impl_from_result ! ( path_find, PathFind ) ;
195195impl_from_result ! ( random, Random ) ;
196196impl_from_result ! ( ripple_path_find, RipplePathFind ) ;
197- impl_from_result ! ( server_info, ServerInfo ) ;
198- impl_from_result ! ( server_state, ServerState ) ;
197+ impl < ' a > From < server_info:: ServerInfo < ' a > > for XRPLResult < ' a > {
198+ fn from ( value : server_info:: ServerInfo < ' a > ) -> Self {
199+ XRPLResult :: ServerInfo ( Box :: new ( value) )
200+ }
201+ }
202+ impl < ' a > From < server_state:: ServerState < ' a > > for XRPLResult < ' a > {
203+ fn from ( value : server_state:: ServerState < ' a > ) -> Self {
204+ XRPLResult :: ServerState ( Box :: new ( value) )
205+ }
206+ }
199207impl_from_result ! ( submit, Submit ) ;
200208impl_from_result ! ( submit_multisigned, SubmitMultisigned ) ;
201209impl_from_result ! ( transaction_entry, TransactionEntry ) ;
@@ -319,8 +327,34 @@ impl_try_from_result!(no_ripple_check, NoRippleCheck, NoRippleCheck);
319327impl_try_from_result ! ( path_find, PathFind , PathFind ) ;
320328impl_try_from_result ! ( random, Random , Random ) ;
321329impl_try_from_result ! ( ripple_path_find, RipplePathFind , RipplePathFind ) ;
322- impl_try_from_result ! ( server_info, ServerInfo , ServerInfo ) ;
323- impl_try_from_result ! ( server_state, ServerState , ServerState ) ;
330+ impl < ' a > TryFrom < XRPLResult < ' a > > for server_info:: ServerInfo < ' a > {
331+ type Error = XRPLModelException ;
332+
333+ fn try_from ( result : XRPLResult < ' a > ) -> XRPLModelResult < Self > {
334+ match result {
335+ XRPLResult :: ServerInfo ( value) => Ok ( * value) ,
336+ res => Err ( XRPLResultException :: UnexpectedResultType (
337+ "ServerInfo" . to_string ( ) ,
338+ res. get_name ( ) ,
339+ )
340+ . into ( ) ) ,
341+ }
342+ }
343+ }
344+ impl < ' a > TryFrom < XRPLResult < ' a > > for server_state:: ServerState < ' a > {
345+ type Error = XRPLModelException ;
346+
347+ fn try_from ( result : XRPLResult < ' a > ) -> XRPLModelResult < Self > {
348+ match result {
349+ XRPLResult :: ServerState ( value) => Ok ( * value) ,
350+ res => Err ( XRPLResultException :: UnexpectedResultType (
351+ "ServerState" . to_string ( ) ,
352+ res. get_name ( ) ,
353+ )
354+ . into ( ) ) ,
355+ }
356+ }
357+ }
324358impl_try_from_result ! ( submit, Submit , Submit ) ;
325359impl_try_from_result ! ( submit_multisigned, SubmitMultisigned , SubmitMultisigned ) ;
326360impl_try_from_result ! ( transaction_entry, TransactionEntry , TransactionEntry ) ;
@@ -545,8 +579,40 @@ impl_try_from_response!(path_find, PathFind, PathFind);
545579impl_try_from_response ! ( ping, Ping , Ping ) ;
546580impl_try_from_response ! ( random, Random , Random ) ;
547581impl_try_from_response ! ( ripple_path_find, RipplePathFind , RipplePathFind ) ;
548- impl_try_from_response ! ( server_info, ServerInfo , ServerInfo ) ;
549- impl_try_from_response ! ( server_state, ServerState , ServerState ) ;
582+ impl < ' a > TryFrom < XRPLResponse < ' a > > for server_info:: ServerInfo < ' a > {
583+ type Error = XRPLModelException ;
584+
585+ fn try_from ( response : XRPLResponse < ' a > ) -> XRPLModelResult < Self > {
586+ match response. result {
587+ Some ( result) => match result {
588+ XRPLResult :: ServerInfo ( value) => Ok ( * value) ,
589+ res => Err ( XRPLResultException :: UnexpectedResultType (
590+ "ServerInfo" . to_string ( ) ,
591+ res. get_name ( ) ,
592+ )
593+ . into ( ) ) ,
594+ } ,
595+ None => Err ( XRPLModelException :: MissingField ( "result" . to_string ( ) ) ) ,
596+ }
597+ }
598+ }
599+ impl < ' a > TryFrom < XRPLResponse < ' a > > for server_state:: ServerState < ' a > {
600+ type Error = XRPLModelException ;
601+
602+ fn try_from ( response : XRPLResponse < ' a > ) -> XRPLModelResult < Self > {
603+ match response. result {
604+ Some ( result) => match result {
605+ XRPLResult :: ServerState ( value) => Ok ( * value) ,
606+ res => Err ( XRPLResultException :: UnexpectedResultType (
607+ "ServerState" . to_string ( ) ,
608+ res. get_name ( ) ,
609+ )
610+ . into ( ) ) ,
611+ } ,
612+ None => Err ( XRPLModelException :: MissingField ( "result" . to_string ( ) ) ) ,
613+ }
614+ }
615+ }
550616impl_try_from_response ! ( submit, Submit , Submit ) ;
551617impl_try_from_response ! ( submit_multisigned, SubmitMultisigned , SubmitMultisigned ) ;
552618impl_try_from_response ! ( transaction_entry, TransactionEntry , TransactionEntry ) ;
0 commit comments