pub struct SField<T, const CODE: i32> { /* private fields */ }Expand description
A type-safe wrapper for XRPL serialized field codes.
This struct encodes both the field code and the expected type as const generics,
allowing the compiler to automatically infer the correct type when calling get_field.
The type parameter T represents the expected Rust type for this field, which can be
used with the field-decoder marker traits FromCurrentTx and FromLedger.
§Example
use xrpl_common_stdlib::objects::ledger_object;
use xrpl_common_stdlib::current_tx;
use xrpl_common_stdlib::types::amount::Amount;
use xrpl_common_stdlib::sfield;
use xrpl_common_stdlib::types::account_id::AccountID;
// Type is automatically inferred from the SField constant, for both ledger_objects and current_transaction:
let flags:u32 = ledger_object::get_field(0, sfield::Flags).unwrap(); // u32
let balance:Amount = ledger_object::get_field(0, sfield::Balance).unwrap(); // u64
// current transaction:
let account:AccountID = current_tx::get_field(sfield::Account).unwrap(); // AccountID
let sequence:u32 = current_tx::get_field(sfield::Sequence).unwrap(); // u32Implementations§
Trait Implementations§
impl<T: Copy, const CODE: i32> Copy for SField<T, CODE>
impl<T: Eq, const CODE: i32> Eq for SField<T, CODE>
impl<T: PartialEq, const CODE: i32> StructuralPartialEq for SField<T, CODE>
Auto Trait Implementations§
impl<T, const CODE: i32> Freeze for SField<T, CODE>where
PhantomData<T>: Freeze,
impl<T, const CODE: i32> RefUnwindSafe for SField<T, CODE>where
PhantomData<T>: RefUnwindSafe,
impl<T, const CODE: i32> Send for SField<T, CODE>where
PhantomData<T>: Send,
impl<T, const CODE: i32> Sync for SField<T, CODE>where
PhantomData<T>: Sync,
impl<T, const CODE: i32> Unpin for SField<T, CODE>where
PhantomData<T>: Unpin,
impl<T, const CODE: i32> UnsafeUnpin for SField<T, CODE>where
PhantomData<T>: UnsafeUnpin,
impl<T, const CODE: i32> UnwindSafe for SField<T, CODE>where
PhantomData<T>: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more