pub struct Object { /* private fields */ }
Expand description
An Object in memory. This is not used to serialize data
Implementations§
Source§impl Object
impl Object
Sourcepub fn new(
content: ObjectContent,
header: Option<CommitHeader>,
block_size: usize,
store: &Store,
) -> Object
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 contentheader
: CommitHeaderV0 : All references of the objectblock_size
: Desired block size for chunking content, will be rounded up to nearest valid block sizestore
: store public key, needed to generate the convergence keystore_secret
: store’s read capability secret, needed to generate the convergence key
pub fn new_with_convergence_key( content: ObjectContent, header: Option<CommitHeader>, block_size: usize, conv_key: &ChaCha20Key, ) -> Object
Sourcepub fn load_ref(
reference: &ObjectRef,
store: &Store,
) -> Result<Object, ObjectParseError>
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
pub fn load_header( root_block: &Block, store: &Store, ) -> Result<Option<CommitHeader>, ObjectParseError>
Sourcepub fn load(
id: ObjectId,
key: Option<SymKey>,
store: &Store,
) -> Result<Object, ObjectParseError>
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
pub fn load_without_header( id: ObjectId, key: Option<SymKey>, store: &Store, ) -> Result<Object, ObjectParseError>
Sourcepub fn save(&self, store: &Store) -> Result<Vec<BlockId>, StorageError>
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
Sourcepub fn get_and_save_id(&mut self) -> ObjectId
pub fn get_and_save_id(&mut self) -> ObjectId
Get the ID of the Object and saves it
pub fn is_root(&self) -> bool
Sourcepub fn deps(&self) -> Vec<ObjectId> ⓘ
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
Sourcepub fn acks_and_nacks(&self) -> Vec<ObjectId> ⓘ
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
Sourcepub fn acks(&self) -> Vec<ObjectId> ⓘ
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
pub fn root_block(&self) -> &Block
pub fn header(&self) -> &Option<CommitHeader>
pub fn blocks(&self) -> impl Iterator<Item = &Block> + '_
pub fn all_blocks_len(&self) -> usize
pub fn blocks_len(&self) -> usize
pub fn header_blocks_len(&self) -> usize
pub fn size(&self) -> usize
pub fn dedup_size(&self) -> usize
pub fn hashmap(&self) -> &HashMap<BlockId, Block>
pub fn into_blocks(self) -> Vec<Block>
Sourcepub fn content(&self) -> Result<ObjectContent, ObjectParseError>
pub fn content(&self) -> Result<ObjectContent, ObjectParseError>
Parse the Object and return the decrypted content assembled from Blocks
Sourcepub fn depth(&self) -> Result<u8, ObjectParseError>
pub fn depth(&self) -> Result<u8, ObjectParseError>
Parse the Object returns the depth of the tree