Skip to main content

SeedStore

Trait SeedStore 

Source
pub trait SeedStore {
    // Required methods
    fn put_node(&mut self, canonical: &[u8]) -> Result<NodeId>;
    fn get_node(&self, id: &NodeId) -> Result<Vec<u8>>;
    fn get_node_range(
        &self,
        id: &NodeId,
        offset: u64,
        len: u64,
    ) -> Result<Vec<u8>>;
    fn contains_node(&self, id: &NodeId) -> Result<bool>;
    fn list_nodes(&self) -> Result<Vec<(NodeId, u64)>>;
}
Expand description

A content-addressed store of canonical procedural seed nodes.

put takes &mut self (ids are content-derived, so retries are idempotent).

Required Methods§

Source

fn put_node(&mut self, canonical: &[u8]) -> Result<NodeId>

Store the canonical bytes of one node, returning its content id.

Idempotent and at-least-once: identical bytes always return the same id and are stored once. A returned id guarantees the bytes are durable under SeedStore::get_node.

Source

fn get_node(&self, id: &NodeId) -> Result<Vec<u8>>

Fetch the exact canonical bytes for id.

MUST verify NodeId::of_node(bytes) == id before returning.

Source

fn get_node_range(&self, id: &NodeId, offset: u64, len: u64) -> Result<Vec<u8>>

Fetch len bytes of id starting at offset (strict; no EOF clip).

Source

fn contains_node(&self, id: &NodeId) -> Result<bool>

Whether id is present.

Source

fn list_nodes(&self) -> Result<Vec<(NodeId, u64)>>

Every stored (id, canonical_len), for closure checking and GC.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§