Struct Object

Source
pub struct Object { /* private fields */ }
Expand description

An Object in memory. This is not used to serialize data

Implementations§

Source§

impl Object

Source

pub fn new( content: ObjectContent, header: Option<CommitHeader>, block_size: usize, store: &Store, ) -> Object

Create new Object from given content

The Object is chunked and stored in a Merkle tree The arity of the Merkle tree is the maximum that fits in the given max_object_size

Arguments:

  • content: Object content
  • header: CommitHeaderV0 : All references of the object
  • block_size: Desired block size for chunking content, will be rounded up to nearest valid block size
  • store: store public key, needed to generate the convergence key
  • store_secret: store’s read capability secret, needed to generate the convergence key
Source

pub fn new_with_convergence_key( content: ObjectContent, header: Option<CommitHeader>, block_size: usize, conv_key: &ChaCha20Key, ) -> Object

Source

pub fn load_ref( reference: &ObjectRef, store: &Store, ) -> Result<Object, ObjectParseError>

Load an Object from BlockStorage (taking a reference)

Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec of ObjectId)) of missing BlockIds

Source

pub fn load_header( root_block: &Block, store: &Store, ) -> Result<Option<CommitHeader>, ObjectParseError>

Source

pub fn load( id: ObjectId, key: Option<SymKey>, store: &Store, ) -> Result<Object, ObjectParseError>

Load an Object from BlockStorage

Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec of ObjectId )) of missing BlockIds

Source

pub fn load_without_header( id: ObjectId, key: Option<SymKey>, store: &Store, ) -> Result<Object, ObjectParseError>

Source

pub fn save(&self, store: &Store) -> Result<Vec<BlockId>, StorageError>

Save blocks of the object and the blocks of the header object in the store

Source

pub fn id(&self) -> ObjectId

Get the ID of the Object

Source

pub fn get_and_save_id(&mut self) -> ObjectId

Get the ID of the Object and saves it

Source

pub fn key(&self) -> Option<SymKey>

Get the key for the Object

Source

pub fn reference(&self) -> Option<ObjectRef>

Get an ObjectRef for the root object

Source

pub fn is_root(&self) -> bool

Source

pub fn deps(&self) -> Vec<ObjectId>

Get deps (that have an ID in the header, without checking if there is a key for them in the header_keys) if there is no header, returns an empty vec

Source

pub fn acks_and_nacks(&self) -> Vec<ObjectId>

Get acks and nacks (that have an ID in the header, without checking if there is a key for them in the header_keys) if there is no header, returns an empty vec

Source

pub fn acks(&self) -> Vec<ObjectId>

Get acks (that have an ID in the header, without checking if there is a key for them in the header_keys) if there is no header, returns an empty vec

Source

pub fn root_block(&self) -> &Block

Source

pub fn header(&self) -> &Option<CommitHeader>

Source

pub fn blocks(&self) -> impl Iterator<Item = &Block> + '_

Source

pub fn all_blocks_len(&self) -> usize

Source

pub fn blocks_len(&self) -> usize

Source

pub fn header_blocks_len(&self) -> usize

Source

pub fn size(&self) -> usize

Source

pub fn dedup_size(&self) -> usize

Source

pub fn hashmap(&self) -> &HashMap<BlockId, Block>

Source

pub fn into_blocks(self) -> Vec<Block>

Source

pub fn content(&self) -> Result<ObjectContent, ObjectParseError>

Parse the Object and return the decrypted content assembled from Blocks

Source

pub fn depth(&self) -> Result<u8, ObjectParseError>

Parse the Object returns the depth of the tree

Source

pub fn content_v0(&self) -> Result<ObjectContentV0, ObjectParseError>

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

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 Object

Source§

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

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

impl Display for Object

Source§

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

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

impl IObject for Object

Source§

impl PartialEq for Object

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Object

Source§

impl StructuralPartialEq for Object

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

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

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.
Source§

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

Source§

fn vzip(self) -> V