Struct iroh_blobs::format::collection::Collection
source · pub struct Collection { /* private fields */ }
Expand description
A collection of blobs
Note that the format is subject to change.
Implementations§
source§impl Collection
impl Collection
sourcepub const HEADER: &'static [u8; 13] = b"CollectionV0."
pub const HEADER: &'static [u8; 13] = b"CollectionV0."
The header for the collection format.
This is the start of the metadata blob.
sourcepub fn to_blobs(&self) -> impl DoubleEndedIterator<Item = Bytes>
pub fn to_blobs(&self) -> impl DoubleEndedIterator<Item = Bytes>
Convert the collection to an iterator of blobs, with the last being the root blob.
To persist the collection, write all the blobs to storage, and use the hash of the last blob as the collection hash.
sourcepub async fn read_fsm(
fsm_at_start_root: AtStartRoot
) -> Result<(EndBlobNext, HashSeq, Collection)>
pub async fn read_fsm( fsm_at_start_root: AtStartRoot ) -> Result<(EndBlobNext, HashSeq, Collection)>
Read the collection from a get fsm.
Returns the fsm at the start of the first child blob (if any), the links array, and the collection.
sourcepub async fn read_fsm_all(
fsm_at_start_root: AtStartRoot
) -> Result<(Collection, BTreeMap<u64, Bytes>, Stats)>
pub async fn read_fsm_all( fsm_at_start_root: AtStartRoot ) -> Result<(Collection, BTreeMap<u64, Bytes>, Stats)>
Read the collection and all it’s children from a get fsm.
Returns the collection, a map from blob offsets to bytes, and the stats.
sourcepub async fn load(root: Hash, store: &impl SimpleStore) -> Result<Self>
pub async fn load(root: Hash, store: &impl SimpleStore) -> Result<Self>
Create a new collection from a hash sequence and metadata.
sourcepub async fn load_db<D>(db: &D, root: &Hash) -> Result<Self>where
D: Map,
pub async fn load_db<D>(db: &D, root: &Hash) -> Result<Self>where
D: Map,
Load a collection from a store given a root hash
This assumes that both the links and the metadata of the collection is stored in the store. It does not require that all child blobs are stored in the store.
sourcepub async fn store<D>(self, db: &D) -> Result<TempTag>where
D: Store,
pub async fn store<D>(self, db: &D) -> Result<TempTag>where
D: Store,
Store a collection in a store. returns the root hash of the collection as a TempTag.
Trait Implementations§
source§impl Clone for Collection
impl Clone for Collection
source§fn clone(&self) -> Collection
fn clone(&self) -> Collection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Collection
impl Debug for Collection
source§impl Default for Collection
impl Default for Collection
source§fn default() -> Collection
fn default() -> Collection
source§impl<'de> Deserialize<'de> for Collection
impl<'de> Deserialize<'de> for Collection
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>,
source§impl<K, V> Extend<(K, V)> for Collection
impl<K, V> Extend<(K, V)> for Collection
source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<K, V> FromIterator<(K, V)> for Collection
impl<K, V> FromIterator<(K, V)> for Collection
source§impl Index<usize> for Collection
impl Index<usize> for Collection
source§impl IntoIterator for Collection
impl IntoIterator for Collection
source§impl PartialEq for Collection
impl PartialEq for Collection
source§fn eq(&self, other: &Collection) -> bool
fn eq(&self, other: &Collection) -> bool
self
and other
values to be equal, and is used
by ==
.