pub struct UserChainData {
pub nonce: u64,
pub transactions: Vec<UserTransactionData>,
}Fields§
§nonce: u64§transactions: Vec<UserTransactionData>Implementations§
Source§impl UserChainData
impl UserChainData
Sourcepub fn default() -> Self
pub fn default() -> Self
Creates a default ChainData with nonce 0 and an empty transactions vector.
pub fn new(transaction: UserTransactionData) -> Self
Sourcepub fn add(&mut self, nonce: u64, transaction: UserTransactionData)
pub fn add(&mut self, nonce: u64, transaction: UserTransactionData)
Adds a new transaction to the chain and updates the nonce.
Sourcepub fn remove(
&mut self,
index: usize,
) -> Result<&UserTransactionData, UserStateError>
pub fn remove( &mut self, index: usize, ) -> Result<&UserTransactionData, UserStateError>
Removes a transaction from the specified chain and updates the ChainData. Returns an error if the chain_id is not found. Returns an error if the transaction index is not found.
Sourcepub fn get_transaction(
&self,
index: usize,
) -> Result<&UserTransactionData, UserStateError>
pub fn get_transaction( &self, index: usize, ) -> Result<&UserTransactionData, UserStateError>
Returns a reference to the transaction at the specified index.
pub fn get_transactions(&self) -> &Vec<UserTransactionData>
Sourcepub fn add_transaction(
&mut self,
nonce: u64,
transaction: UserTransactionData,
) -> Result<&UserTransactionData, UserStateError>
pub fn add_transaction( &mut self, nonce: u64, transaction: UserTransactionData, ) -> Result<&UserTransactionData, UserStateError>
Adds a transaction to the specified chain and updates the ChainData. Returns an error if the chain_id is not found.
Sourcepub fn clear_transactions(&mut self)
pub fn clear_transactions(&mut self)
Clears the transactions vector for the specified chain. Returns an error if the chain_id is not found.
Trait Implementations§
Source§impl CandidType for UserChainData
impl CandidType for UserChainData
Source§impl Clone for UserChainData
impl Clone for UserChainData
Source§fn clone(&self) -> UserChainData
fn clone(&self) -> UserChainData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UserChainData
impl Debug for UserChainData
Source§impl<'de> Deserialize<'de> for UserChainData
impl<'de> Deserialize<'de> for UserChainData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for UserChainData
impl PartialEq for UserChainData
impl StructuralPartialEq for UserChainData
Auto Trait Implementations§
impl Freeze for UserChainData
impl RefUnwindSafe for UserChainData
impl Send for UserChainData
impl Sync for UserChainData
impl Unpin for UserChainData
impl UnwindSafe for UserChainData
Blanket Implementations§
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