pub struct LedgerSnapshot {
    pub protocol_version: u32,
    pub sequence_number: u32,
    pub timestamp: u64,
    pub network_id: [u8; 32],
    pub base_reserve: u32,
    pub ledger_entries: Vec<(Box<LedgerKey>, Box<LedgerEntry>)>,
}
Expand description

Ledger snapshot stores a snapshot of a ledger that can be restored for use in environments as a LedgerInfo and a SnapshotSource.

Fields§

§protocol_version: u32§sequence_number: u32§timestamp: u64§network_id: [u8; 32]§base_reserve: u32§ledger_entries: Vec<(Box<LedgerKey>, Box<LedgerEntry>)>

Implementations§

source§

impl LedgerSnapshot

source

pub fn from<'a>( info: LedgerInfo, entries: impl IntoIterator<Item = (&'a Box<LedgerKey>, &'a Box<LedgerEntry>)> ) -> Self

source

pub fn update(&mut self, host: &Host)

Update the snapshot with the state within the given Host.

The ledger info of the host will overwrite the ledger info in the snapshot. The entries in the host’s storage will overwrite entries in the snapshot. Existing entries in the snapshot that are untouched by the host will remain.

source

pub fn ledger_info(&self) -> LedgerInfo

source

pub fn set_ledger_info(&mut self, info: LedgerInfo)

Set the ledger info in the snapshot.

source

pub fn entries( &self ) -> impl IntoIterator<Item = (&Box<LedgerKey>, &Box<LedgerEntry>)>

Get the entries in the snapshot.

source

pub fn set_entries<'a>( &mut self, entries: impl IntoIterator<Item = (&'a Box<LedgerKey>, &'a Box<LedgerEntry>)> )

Replace the entries in the snapshot with the entries in the iterator.

source

pub fn update_entries<'a>( &mut self, entries: impl IntoIterator<Item = &'a (Rc<LedgerKey>, Option<Rc<LedgerEntry>>)> )

Update entries in the snapshot by adding or replacing any entries that have entry in the input iterator, or removing any that does not have an entry.

source§

impl LedgerSnapshot

source

pub fn read(r: impl Read) -> Result<LedgerSnapshot, Error>

source

pub fn read_file(p: impl AsRef<Path>) -> Result<LedgerSnapshot, Error>

source

pub fn write(&self, w: impl Write) -> Result<(), Error>

source

pub fn write_file(&self, p: impl AsRef<Path>) -> Result<(), Error>

Trait Implementations§

source§

impl Clone for LedgerSnapshot

source§

fn clone(&self) -> LedgerSnapshot

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LedgerSnapshot

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for LedgerSnapshot

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for LedgerSnapshot

source§

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<LedgerSnapshot> for LedgerSnapshot

source§

fn eq(&self, other: &LedgerSnapshot) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for LedgerSnapshot

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SnapshotSource for &LedgerSnapshot

source§

fn get(&self, key: &LedgerKey) -> Result<LedgerEntry, HostError>

source§

fn has(&self, key: &LedgerKey) -> Result<bool, HostError>

source§

impl SnapshotSource for LedgerSnapshot

source§

fn get(&self, key: &LedgerKey) -> Result<LedgerEntry, HostError>

source§

fn has(&self, key: &LedgerKey) -> Result<bool, HostError>

source§

impl Eq for LedgerSnapshot

source§

impl StructuralEq for LedgerSnapshot

source§

impl StructuralPartialEq for LedgerSnapshot

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<T, C> Compare<&T> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare(&self, a: &&T, b: &&T) -> Result<Ordering, <C as Compare<&T>>::Error>

§

impl<T, U, E, C> Compare<(T, U)> for Cwhere C: Compare<T, Error = E, Error = E> + Compare<U>,

§

type Error = E

§

fn compare( &self, a: &(T, U), b: &(T, U) ) -> Result<Ordering, <C as Compare<(T, U)>>::Error>

§

impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,

§

type Error = E

§

fn compare( &self, a: &(T, U, V), b: &(T, U, V) ) -> Result<Ordering, <C as Compare<(T, U, V)>>::Error>

§

impl<T, C> Compare<Box<T, Global>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Box<T, Global>, b: &Box<T, Global> ) -> Result<Ordering, <C as Compare<Box<T, Global>>>::Error>

§

impl<T, C> Compare<Option<T>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Option<T>, b: &Option<T> ) -> Result<Ordering, <C as Compare<Option<T>>>::Error>

§

impl<T, C> Compare<Rc<T>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Rc<T>, b: &Rc<T> ) -> Result<Ordering, <C as Compare<Rc<T>>>::Error>

§

impl<T, C> Compare<Vec<T, Global>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Vec<T, Global>, b: &Vec<T, Global> ) -> Result<Ordering, <C as Compare<Vec<T, Global>>>::Error>

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<E, T, U> TryIntoVal<E, T> for Uwhere E: Env, T: TryFromVal<E, U>,

§

type Error = <T as TryFromVal<E, U>>::Error

§

fn try_into_val(&self, env: &E) -> Result<T, <U as TryIntoVal<E, T>>::Error>

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,