Skip to main content

CachedChain

Struct CachedChain 

Source
pub struct CachedChain<F> { /* private fields */ }
Expand description

A ChainStorage that reads each slot once, through a function the frontend gives.

The reading is the frontend’s — this crate opens no connections — but the caching and the labelling are the same wherever the words come from, so they live here rather than once per frontend.

Implementations§

Source§

impl<F> CachedChain<F>
where F: Fn(&str, &Word) -> Option<Word>,

Source

pub fn new(label: impl Into<String>, read: F) -> Self

label says where the words come from, as a user-facing phrase such as the chain at block 21000000.

Trait Implementations§

Source§

impl<F> ChainStorage for CachedChain<F>
where F: Fn(&str, &Word) -> Option<Word>,

Source§

fn word(&self, address: &str, slot: &Word) -> Option<Word>

The word at slot of address, or None when it could not be read.
Source§

fn label(&self) -> &str

Where these words come from, as a user-facing phrase such as the chain at block 21000000.
Source§

impl<F> Debug for CachedChain<F>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> !Freeze for CachedChain<F>

§

impl<F> !RefUnwindSafe for CachedChain<F>

§

impl<F> !Sync for CachedChain<F>

§

impl<F> Send for CachedChain<F>
where F: Send,

§

impl<F> Unpin for CachedChain<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for CachedChain<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for CachedChain<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.