Struct sn_data_types::register::Register[][src]

pub struct Register { /* fields omitted */ }

Object storing the Register

Implementations

impl Register[src]

pub fn new_public(
    authority: PublicKey,
    name: XorName,
    tag: u64,
    policy: Option<PublicPolicy>
) -> Self
[src]

Construct a new Public Register. The ‘authority’ is assumed to be the PK which the messages were and will be signed with. If a policy is not provided, a default policy will be set where the ‘authority’ is the owner along with an empty users permissions set.

pub fn new_private(
    authority: PublicKey,
    name: XorName,
    tag: u64,
    policy: Option<PrivatePolicy>
) -> Self
[src]

Construct a new Private Register. The ‘authority’ is assumed to be the PK which the messages were and will be signed with. If a policy is not provided, a default policy will be set where the ‘authority’ is the owner along with an empty users permissions set.

pub fn address(&self) -> &Address[src]

Return the address.

pub fn kind(&self) -> Kind[src]

Return the kind.

pub fn name(&self) -> &XorName[src]

Return the name.

pub fn tag(&self) -> u64[src]

Return the tag.

pub fn is_public(&self) -> bool[src]

Return true if public.

pub fn is_private(&self) -> bool[src]

Return true if private.

pub fn size(&self, requester: Option<PublicKey>) -> Result<u64>[src]

Return the number of items held in the register, optionally verifying read permissions if a pk is provided

pub fn is_empty(&self, requester: Option<PublicKey>) -> Result<bool>[src]

Return true if the register is empty.

pub fn get(
    &self,
    hash: EntryHash,
    requester: Option<PublicKey>
) -> Result<Option<&Entry>>
[src]

Return a value corresponding to the provided ‘hash’, if present.

pub fn read(
    &self,
    requester: Option<PublicKey>
) -> Result<BTreeSet<(EntryHash, Entry)>>
[src]

Read the last entry, or entries when there are branches, if the register is not empty.

pub fn write(
    &mut self,
    entry: Entry,
    parents: BTreeSet<EntryHash>
) -> Result<(EntryHash, RegisterOp<Entry>)>
[src]

Write an entry to the Register, returning the generated unsigned CRDT operation so the caller can sign and broadcast it to other replicas, along with the hash of the entry just written.

pub fn apply_op(&mut self, op: RegisterOp<Entry>) -> Result<()>[src]

Apply a signed data CRDT operation.

pub fn permissions(
    &self,
    user: User,
    requester: Option<PublicKey>
) -> Result<Permissions>
[src]

Return user permissions, if applicable.

pub fn policy(&self, requester: Option<PublicKey>) -> Result<&Policy>[src]

Return the policy.

pub fn check_permission(
    &self,
    action: Action,
    requester: Option<PublicKey>
) -> Result<()>
[src]

Helper to check permissions for given action for the given requester’s public key.

Returns: Ok(()) if the permissions are valid, Err::AccessDenied if the action is not allowed.

pub fn owner(&self) -> PublicKey[src]

Return the owner of the data.

pub fn replica_authority(&self) -> PublicKey[src]

Return the PK which the messages are expected to be signed with by this replica.

Trait Implementations

impl Clone for Register[src]

impl Debug for Register[src]

impl<'de> Deserialize<'de> for Register[src]

impl Eq for Register[src]

impl From<Register> for Data[src]

impl Hash for Register[src]

impl PartialEq<Register> for Register[src]

impl PartialOrd<Register> for Register[src]

impl Serialize for Register[src]

impl StructuralEq for Register[src]

impl StructuralPartialEq for Register[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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