TransparentLog

Trait TransparentLog 

Source
pub trait TransparentLog<'a, T: Serialize + Deserialize<'a>> {
    type LogSize: Integer + Copy + Hash;

    // Required methods
    fn add(&mut self, record: T) -> Result<Self::LogSize>;
    fn add_hash(
        &mut self,
        level: LogHeight,
        hash: String,
    ) -> Result<Self::LogSize>;
    fn get_hash(
        &self,
        level: LogHeight,
        index: Self::LogSize,
    ) -> Result<MaybeOwned<'_, String>>;
    fn size(&self) -> Result<Self::LogSize>;
    fn get(&self, index: Self::LogSize) -> Result<Option<MaybeOwned<'_, T>>>;

    // Provided methods
    fn append(&mut self, record: T) -> Result<Record<Self::LogSize>> { ... }
    fn push_hash(
        &mut self,
        level: LogHeight,
        hash: String,
    ) -> Result<Self::LogSize> { ... }
    fn latest(&self) -> Result<LogTree<Self::LogSize>> { ... }
    fn proofs<I>(
        &self,
        positions: I,
    ) -> Result<HashMap<LogTreePosition<Self::LogSize>, String>>
       where I: Iterator<Item = LogTreePosition<Self::LogSize>> { ... }
}
Expand description

Transparent log Trait

Required Associated Types§

Source

type LogSize: Integer + Copy + Hash

The type used to represent the log size

Required Methods§

Source

fn add(&mut self, record: T) -> Result<Self::LogSize>

Add a record, return the record ID

Source

fn add_hash(&mut self, level: LogHeight, hash: String) -> Result<Self::LogSize>

Add a hash and index, returns the index of the added hash

Source

fn get_hash( &self, level: LogHeight, index: Self::LogSize, ) -> Result<MaybeOwned<'_, String>>

Get a hash at the given level and index

Source

fn size(&self) -> Result<Self::LogSize>

Get the log size

Source

fn get(&self, index: Self::LogSize) -> Result<Option<MaybeOwned<'_, T>>>

Retrieve a log entry by its index

Provided Methods§

Source

fn append(&mut self, record: T) -> Result<Record<Self::LogSize>>

Append a new record to the log and return its index

Source

fn push_hash(&mut self, level: LogHeight, hash: String) -> Result<Self::LogSize>

Recursively push a hash to the tree at given level

Source

fn latest(&self) -> Result<LogTree<Self::LogSize>>

Get the latest log size and root hash

Source

fn proofs<I>( &self, positions: I, ) -> Result<HashMap<LogTreePosition<Self::LogSize>, String>>
where I: Iterator<Item = LogTreePosition<Self::LogSize>>,

Return the requested proofs from the log

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T: Serialize + Deserialize<'a>> TransparentLog<'a, T> for InMemoryLog<T>

TransparentLog Trait implementation for in-memory log

Source§

impl<'a, T: Serialize + DeserializeOwned> TransparentLog<'a, T> for FileLog<'a, T>