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: RepoIdThe canonical identifier for this identity. This is the object id of the initial document blob.
current: RevisionIdThe current revision of the document. Equal to the head of the identity branch.
root: RevisionIdThe 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
impl Identity
pub fn new(revision: Revision) -> Self
pub fn initialize<'a, R, G>( doc: &Doc, store: &'a R, signer: &Device<G>, ) -> Result<IdentityMut<'a, R>, Error>
pub fn get<R: ReadRepository + Store>( object: &ObjectId, repo: &R, ) -> Result<Identity, Error>
Sourcepub fn get_mut<'a, R: WriteRepository + Store<Namespace = NodeId>>(
id: &ObjectId,
repo: &'a R,
) -> Result<IdentityMut<'a, R>, Error>
pub fn get_mut<'a, R: WriteRepository + Store<Namespace = NodeId>>( id: &ObjectId, repo: &'a R, ) -> Result<IdentityMut<'a, R>, Error>
Get a proposal mutably.
pub fn load<R: ReadRepository + Store>( repo: &R, ) -> Result<Identity, RepositoryError>
pub fn load_mut<R: WriteRepository + Store<Namespace = NodeId>>( repo: &R, ) -> Result<IdentityMut<'_, R>, RepositoryError>
Source§impl Identity
impl Identity
Sourcepub fn head(&self) -> Oid
pub fn head(&self) -> Oid
The head of the identity branch. This points to a commit that contains the current document blob.
Sourcepub fn revision(&self, revision: &RevisionId) -> Option<&Revision>
pub fn revision(&self, revision: &RevisionId) -> Option<&Revision>
A specific Revision, that may be redacted.
Sourcepub fn revisions(&self) -> impl DoubleEndedIterator<Item = &Revision>
pub fn revisions(&self) -> impl DoubleEndedIterator<Item = &Revision>
All the Revisions that have not been redacted.
pub fn latest_by(&self, who: &Did) -> Option<&Revision>
Methods from Deref<Target = Revision>§
pub fn signatures(&self) -> impl Iterator<Item = (&PublicKey, Signature)>
pub fn is_accepted(&self) -> bool
pub fn is_active(&self) -> bool
pub fn verdicts(&self) -> impl Iterator<Item = (&PublicKey, &Verdict)>
pub fn accepted(&self) -> impl Iterator<Item = Did> + '_
pub fn rejected(&self) -> impl Iterator<Item = Did> + '_
pub fn sign<G: Signer<Signature>>( &self, signer: &G, ) -> Result<Signature, DocError>
Methods from Deref<Target = Doc>§
Sourcepub fn payload(&self) -> &BTreeMap<PayloadId, Payload>
pub fn payload(&self) -> &BTreeMap<PayloadId, Payload>
Return the associated payloads for this Doc.
Sourcepub fn project(&self) -> Result<Project, PayloadError>
pub fn project(&self) -> Result<Project, PayloadError>
Get the project payload, if it exists and is valid, out of this document.
Sourcepub fn visibility(&self) -> &Visibility
pub fn visibility(&self) -> &Visibility
Return the associated Visibility of this document.
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Check whether the visibility of the document is private.
Sourcepub fn threshold_nonzero(&self) -> &NonZeroUsize
pub fn threshold_nonzero(&self) -> &NonZeroUsize
Return the associated threshold of this document in its non-zero format.
Sourcepub fn is_delegate(&self, did: &Did) -> bool
pub fn is_delegate(&self, did: &Did) -> bool
Check if the did is part of the Doc::delegates set.
Sourcepub fn is_visible_to(&self, did: &Did) -> bool
pub fn is_visible_to(&self, did: &Did) -> bool
Check whether this document and the associated repository is visible to the given peer.
Sourcepub fn verify_signature(
&self,
key: &PublicKey,
signature: &Signature,
blob: Oid,
) -> Result<(), PublicKey>
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.
Sourcepub fn is_majority(&self, votes: usize) -> bool
pub fn is_majority(&self, votes: usize) -> bool
Check the provided votes passes the Doc::majority.
Sourcepub fn majority(&self) -> usize
pub fn majority(&self) -> usize
Return the majority number based on the size of the delegates set.
Sourcepub fn sign<G>(&self, signer: &G) -> Result<(Oid, Vec<u8>, Signature), DocError>
pub fn sign<G>(&self, signer: &G) -> Result<(Oid, Vec<u8>, Signature), DocError>
Doc::encode and sign the Doc, returning the set of bytes, its
corresponding Git Oid and the Signature over the Oid.
Sourcepub fn init<G>(
&self,
repo: &Repository,
signer: &Device<G>,
) -> Result<Oid, RepositoryError>
pub fn init<G>( &self, repo: &Repository, signer: &Device<G>, ) -> Result<Oid, RepositoryError>
Initialize an identity::Identity with this Doc as the associated
document.
Trait Implementations§
Source§impl Cob for Identity
impl Cob for Identity
Source§type Error = ApplyError
type Error = ApplyError
apply function.Source§fn from_root<R: ReadRepository>(op: Op, repo: &R) -> Result<Self, Self::Error>
fn from_root<R: ReadRepository>(op: Op, repo: &R) -> Result<Self, Self::Error>
Source§fn op<'a, R: ReadRepository, I: IntoIterator<Item = &'a Entry>>(
&mut self,
op: Op,
concurrent: I,
repo: &R,
) -> Result<(), ApplyError>
fn op<'a, R: ReadRepository, I: IntoIterator<Item = &'a Entry>>( &mut self, op: Op, concurrent: I, repo: &R, ) -> Result<(), ApplyError>
Source§impl CobWithType for Identity
impl CobWithType for Identity
Source§impl<R: ReadRepository> Evaluate<R> for Identity
impl<R: ReadRepository> Evaluate<R> for Identity
impl Eq for Identity
impl StructuralPartialEq for Identity
Auto Trait Implementations§
impl Freeze for Identity
impl RefUnwindSafe for Identity
impl Send for Identity
impl Sync for Identity
impl Unpin for Identity
impl UnwindSafe for Identity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.