Struct btlib::BlockMetaBody
source · pub struct BlockMetaBody { /* private fields */ }
Expand description
This struct contains all of the metadata fields associated with a block, except for its
signature. Since this struct implements Serialize
, this allows for convenient signature
calculations.
Implementations§
source§impl BlockMetaBody
impl BlockMetaBody
sourcepub fn unlock_block_key_with_parent_key(
&mut self,
parent_key: SymKey
) -> Result<()>
pub fn unlock_block_key_with_parent_key( &mut self, parent_key: SymKey ) -> Result<()>
Uses the given symmetric key to decrypt the inherit
field. If this field is None
, or if
the decryption fails, then an error is returned. If the block key has already been decrypted
then this method does nothing.
sourcepub fn access_secrets<T, F: FnOnce(&mut BlockMetaSecrets) -> Result<T>>(
&mut self,
accessor: F
) -> Result<T>
pub fn access_secrets<T, F: FnOnce(&mut BlockMetaSecrets) -> Result<T>>( &mut self, accessor: F ) -> Result<T>
The given closure is called with the BlockMetaSecrets contained in this struct. Whatever the closure returns is returned by this method (unless an error occurs). The secrets are decrypted, if needed, and after the closure returns they are updated. It’s best to use the BlockMetaBody::secrets method if all you need is read access.
sourcepub fn secrets(&self) -> Result<&BlockMetaSecrets>
pub fn secrets(&self) -> Result<&BlockMetaSecrets>
Returns a reference to the secrets in this struct. This is very cheap operation, just copying a reference.
sourcepub fn block_id(&self) -> Result<&BlockId>
pub fn block_id(&self) -> Result<&BlockId>
Returns the ID of the block this metadata is part of.
sourcepub fn integrity(&self) -> Option<&[u8]>
pub fn integrity(&self) -> Option<&[u8]>
Returns a reference to the integrity value stored in this struct. This value represents the authenticated value of the block’s contents.
sourcepub fn use_readcap_for<C: Creds>(&mut self, creds: &C) -> Result<&SymKey>
pub fn use_readcap_for<C: Creds>(&mut self, creds: &C) -> Result<&SymKey>
Decrypts the readcap for the given Creds and uses the resulting plaintext as the block key.
sourcepub fn add_readcap_for<C: CredsPub>(&mut self, creds: C) -> Result<()>
pub fn add_readcap_for<C: CredsPub>(&mut self, creds: C) -> Result<()>
Adds a new readcap for the given Creds.
Trait Implementations§
source§impl AsMut<BlockMetaBody> for BlockMeta
impl AsMut<BlockMetaBody> for BlockMeta
source§fn as_mut(&mut self) -> &mut BlockMetaBody
fn as_mut(&mut self) -> &mut BlockMetaBody
source§impl AsRef<BlockMetaBody> for BlockMeta
impl AsRef<BlockMetaBody> for BlockMeta
source§fn as_ref(&self) -> &BlockMetaBody
fn as_ref(&self) -> &BlockMetaBody
source§impl Clone for BlockMetaBody
impl Clone for BlockMetaBody
source§fn clone(&self) -> BlockMetaBody
fn clone(&self) -> BlockMetaBody
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BlockMetaBody
impl Debug for BlockMetaBody
source§impl<'de> Deserialize<'de> for BlockMetaBody
impl<'de> Deserialize<'de> for BlockMetaBody
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 PartialEq<BlockMetaBody> for BlockMetaBody
impl PartialEq<BlockMetaBody> for BlockMetaBody
source§fn eq(&self, other: &BlockMetaBody) -> bool
fn eq(&self, other: &BlockMetaBody) -> bool
self
and other
values to be equal, and is used
by ==
.