Struct Identity

Source
pub struct Identity {
    pub id: RepoId,
    pub current: RevisionId,
    pub root: RevisionId,
    pub heads: BTreeMap<Did, RevisionId>,
    /* private fields */
}
Expand description

An evolving identity document.

Fields§

§id: RepoId

The canonical identifier for this identity. This is the object id of the initial document blob.

§current: RevisionId

The current revision of the document. Equal to the head of the identity branch.

§root: RevisionId

The initial revision of the document.

§heads: BTreeMap<Did, RevisionId>

The latest revision that each delegate has accepted. Delegates can only accept one revision at a time.

Implementations§

Source§

impl Identity

Source

pub fn new(revision: Revision) -> Self

Source

pub fn initialize<'a, R, G>( doc: &Doc, store: &'a R, signer: &Device<G>, ) -> Result<IdentityMut<'a, R>, Error>
where G: Signer<Signature>, R: WriteRepository + Store<Namespace = NodeId>,

Source

pub fn get<R: ReadRepository + Store>( object: &ObjectId, repo: &R, ) -> Result<Identity, Error>

Source

pub fn get_mut<'a, R: WriteRepository + Store<Namespace = NodeId>>( id: &ObjectId, repo: &'a R, ) -> Result<IdentityMut<'a, R>, Error>

Get a proposal mutably.

Source

pub fn load<R: ReadRepository + Store>( repo: &R, ) -> Result<Identity, RepositoryError>

Source

pub fn load_mut<R: WriteRepository + Store<Namespace = NodeId>>( repo: &R, ) -> Result<IdentityMut<'_, R>, RepositoryError>

Source§

impl Identity

Source

pub fn id(&self) -> RepoId

The repository identifier.

Source

pub fn doc(&self) -> &Doc

The current document.

Source

pub fn current(&self) -> &Revision

The current revision.

Source

pub fn root(&self) -> &Revision

The initial revision of this identity.

Source

pub fn head(&self) -> Oid

The head of the identity branch. This points to a commit that contains the current document blob.

Source

pub fn revision(&self, revision: &RevisionId) -> Option<&Revision>

A specific Revision, that may be redacted.

Source

pub fn revisions(&self) -> impl DoubleEndedIterator<Item = &Revision>

All the Revisions that have not been redacted.

Source

pub fn latest_by(&self, who: &Did) -> Option<&Revision>

Methods from Deref<Target = Revision>§

Source

pub fn signatures(&self) -> impl Iterator<Item = (&PublicKey, Signature)>

Source

pub fn is_accepted(&self) -> bool

Source

pub fn is_active(&self) -> bool

Source

pub fn verdicts(&self) -> impl Iterator<Item = (&PublicKey, &Verdict)>

Source

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

Source

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

Source

pub fn sign<G: Signer<Signature>>( &self, signer: &G, ) -> Result<Signature, DocError>

Methods from Deref<Target = Doc>§

Source

pub fn version(&self) -> &Version

Get the version of the document.

Source

pub fn payload(&self) -> &BTreeMap<PayloadId, Payload>

Return the associated payloads for this Doc.

Source

pub fn project(&self) -> Result<Project, PayloadError>

Get the project payload, if it exists and is valid, out of this document.

Source

pub fn visibility(&self) -> &Visibility

Return the associated Visibility of this document.

Source

pub fn is_public(&self) -> bool

Check whether the visibility of the document is public.

Source

pub fn is_private(&self) -> bool

Check whether the visibility of the document is private.

Source

pub fn threshold(&self) -> usize

Return the associated threshold of this document.

Source

pub fn threshold_nonzero(&self) -> &NonZeroUsize

Return the associated threshold of this document in its non-zero format.

Source

pub fn delegates(&self) -> &Delegates

Return the associated delegates of this document.

Source

pub fn is_delegate(&self, did: &Did) -> bool

Check if the did is part of the Doc::delegates set.

Source

pub fn is_visible_to(&self, did: &Did) -> bool

Check whether this document and the associated repository is visible to the given peer.

Source

pub fn verify_signature( &self, key: &PublicKey, signature: &Signature, blob: Oid, ) -> Result<(), PublicKey>

Validate signature using this document’s delegates, against a given document blob.

Source

pub fn is_majority(&self, votes: usize) -> bool

Check the provided votes passes the Doc::majority.

Source

pub fn majority(&self) -> usize

Return the majority number based on the size of the delegates set.

Source

pub fn encode(&self) -> Result<(Oid, Vec<u8>), DocError>

Encode the Doc as canonical JSON, returning the set of bytes and its corresponding Git Oid.

Source

pub fn sign<G>(&self, signer: &G) -> Result<(Oid, Vec<u8>, Signature), DocError>
where G: Signer<Signature>,

Doc::encode and sign the Doc, returning the set of bytes, its corresponding Git Oid and the Signature over the Oid.

Source

pub fn signature_of<G>(&self, signer: &G) -> Result<Signature, DocError>
where G: Signer<Signature>,

Similar to Doc::sign, but only returning the Signature.

Source

pub fn init<G>( &self, repo: &Repository, signer: &Device<G>, ) -> Result<Oid, RepositoryError>
where G: Signer<Signature>,

Initialize an identity::Identity with this Doc as the associated document.

Trait Implementations§

Source§

impl Clone for Identity

Source§

fn clone(&self) -> Identity

Returns a duplicate 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 Cob for Identity

Source§

type Action = Action

The underlying action composing each operation.
Source§

type Error = ApplyError

Error returned by apply function.
Source§

fn from_root<R: ReadRepository>(op: Op, repo: &R) -> Result<Self, Self::Error>

Initialize a collaborative object from a root operation.
Source§

fn op<'a, R: ReadRepository, I: IntoIterator<Item = &'a Entry>>( &mut self, op: Op, concurrent: I, repo: &R, ) -> Result<(), ApplyError>

Apply an operation to the state.
Source§

impl CobWithType for Identity

Source§

fn type_name() -> &'static TypeName

The type name of the collaborative object type which backs this implementation.
Source§

impl Debug for Identity

Source§

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

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

impl Deref for Identity

Source§

type Target = Revision

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<R: ReadRepository> Evaluate<R> for Identity

Source§

type Error = Error

Source§

fn init(entry: &Entry, repo: &R) -> Result<Self, Self::Error>

Initialize the object with the first (root) history entry.
Source§

fn apply<'a, I: Iterator<Item = (&'a EntryId, &'a Entry)>>( &mut self, entry: &Entry, concurrent: I, repo: &R, ) -> Result<(), Self::Error>

Apply a history entry to the evaluated state.
Source§

impl PartialEq for Identity

Source§

fn eq(&self, other: &Identity) -> 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 Serialize for Identity

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Identity

Source§

impl StructuralPartialEq for Identity

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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, 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<T> ErasedDestructor for T
where T: 'static,