pub struct Memory(/* private fields */);Expand description
A basic implementation of Wallet that doesn’t persist anything and merely tracks the
chains in memory.
This can be used as-is as an ephemeral wallet for testing or ephemeral clients, or as a building block for more complex wallets that layer persistence on top of it.
Implementations§
Source§impl Memory
impl Memory
pub fn get(&self, id: ChainId) -> Option<Chain>
pub fn insert(&self, id: ChainId, chain: Chain) -> Option<Chain>
pub fn try_insert(&self, id: ChainId, chain: Chain) -> Option<Chain>
pub fn remove(&self, id: ChainId) -> Option<Chain>
pub fn items(&self) -> Vec<(ChainId, Chain)>
pub fn chain_ids(&self) -> Vec<ChainId>
pub fn owned_chain_ids(&self) -> Vec<ChainId>
pub fn mutate<R>( &self, chain_id: ChainId, mutate: impl FnMut(&mut Chain) -> R, ) -> Option<R>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Memory
impl<'de> Deserialize<'de> for Memory
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 Extend<(ChainId, Chain)> for Memory
impl Extend<(ChainId, Chain)> for Memory
Source§fn extend<It: IntoIterator<Item = (ChainId, Chain)>>(&mut self, chains: It)
fn extend<It: IntoIterator<Item = (ChainId, Chain)>>(&mut self, chains: It)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl Serialize for Memory
Custom Serialize implementation that ensures stable ordering by sorting entries by ChainId.
impl Serialize for Memory
Custom Serialize implementation that ensures stable ordering by sorting entries by ChainId.
Source§impl Wallet for Memory
impl Wallet for Memory
type Error = Infallible
async fn get(&self, id: ChainId) -> Result<Option<Chain>, Self::Error>
async fn insert( &self, id: ChainId, chain: Chain, ) -> Result<Option<Chain>, Self::Error>
async fn try_insert( &self, id: ChainId, chain: Chain, ) -> Result<Option<Chain>, Self::Error>
async fn remove(&self, id: ChainId) -> Result<Option<Chain>, Self::Error>
fn items(&self) -> impl Stream<Item = Result<(ChainId, Chain), Self::Error>>
Source§async fn modify(
&self,
id: ChainId,
f: impl FnMut(&mut Chain) + Send,
) -> Result<Option<()>, Self::Error>
async fn modify( &self, id: ChainId, f: impl FnMut(&mut Chain) + Send, ) -> Result<Option<()>, Self::Error>
Modifies a chain in the wallet. Returns
Ok(None) if the chain doesn’t exist.fn chain_ids(&self) -> impl Stream<Item = Result<ChainId, Self::Error>> + Send
fn owned_chain_ids( &self, ) -> impl Stream<Item = Result<ChainId, Self::Error>> + Send
Auto Trait Implementations§
impl !Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl !UnwindSafe for Memory
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
Source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length bytes from memory from the provided location.
Source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes to memory at the provided location.