[][src]Trait safe_nd::AppendOnlyData

pub trait AppendOnlyData<P> {
    fn get(&self, key: &[u8]) -> Option<&Vec<u8>>;
fn last_entry(&self) -> Option<&Entry>;
fn in_range(&self, start: Index, end: Index) -> Option<Entries>;
fn entries(&self) -> &Entries;
fn address(&self) -> &Address;
fn name(&self) -> &XorName;
fn tag(&self) -> u64;
fn entries_index(&self) -> u64;
fn owners_index(&self) -> u64;
fn permissions_index(&self) -> u64;
fn permissions_range(&self, start: Index, end: Index) -> Option<&[P]>;
fn append_permissions(
        &mut self,
        permissions: P,
        permissions_index: u64
    ) -> Result<()>;
fn permissions(&self, perm_index: impl Into<Index>) -> Option<&P>;
fn owner(&self, owners_index: impl Into<Index>) -> Option<&Owner>;
fn owners_range(&self, start: Index, end: Index) -> Option<&[Owner]>;
fn append_owner(&mut self, owner: Owner, owners_index: u64) -> Result<()>;
fn check_is_last_owner(&self, requester: PublicKey) -> Result<()>; }

Common methods for all AppendOnlyData flavours.

Required methods

fn get(&self, key: &[u8]) -> Option<&Vec<u8>>

Returns a value for the given key, if present.

fn last_entry(&self) -> Option<&Entry>

Returns the last entry, if present.

fn in_range(&self, start: Index, end: Index) -> Option<Entries>

Gets a list of keys and values with the given indices.

fn entries(&self) -> &Entries

Returns all entries.

fn address(&self) -> &Address

Returns the address.

fn name(&self) -> &XorName

Returns the name.

fn tag(&self) -> u64

Returns the type tag.

fn entries_index(&self) -> u64

Returns the last entry index.

fn owners_index(&self) -> u64

Returns the last owners index.

fn permissions_index(&self) -> u64

Returns the last permissions index.

fn permissions_range(&self, start: Index, end: Index) -> Option<&[P]>

Gets a complete list of permissions from the entry in the permissions list at the specified indices.

fn append_permissions(
    &mut self,
    permissions: P,
    permissions_index: u64
) -> Result<()>

Adds a new permissions entry. The Perm struct should contain valid indices.

If the specified permissions_index does not match the last recorded permissions index + 1, an error will be returned.

fn permissions(&self, perm_index: impl Into<Index>) -> Option<&P>

Fetches permissions at index.

fn owner(&self, owners_index: impl Into<Index>) -> Option<&Owner>

Fetches owner at index.

fn owners_range(&self, start: Index, end: Index) -> Option<&[Owner]>

Gets a complete list of owners from the entry in the permissions list at the specified index.

fn append_owner(&mut self, owner: Owner, owners_index: u64) -> Result<()>

Adds a new owner entry.

If the specified owners_index does not match the last recorded owners index + 1, an error will be returned.

fn check_is_last_owner(&self, requester: PublicKey) -> Result<()>

Checks if the requester is the last owner.

Returns: Ok(()) if the requester is the owner, Err::InvalidOwners if the last owner is invalid, Err::AccessDenied if the requester is not the owner.

Loading content...

Implementors

Loading content...