pub struct Doc { /* private fields */ }Expand description
Doc is a valid identity document.
To ensure that only valid documents are used, this type is restricted to be
read-only. For mutating the document use Doc::edit.
A valid Doc can be constructed in four ways:
Doc::initial: a safe way to construct the initial document for an identity.RawDoc::verified: validates aRawDoc’s fields and converts it into aDocDeserialize: will deserialize aDocby first deserializing aRawDocand useRawDoc::verifiedto construct theDoc.Doc::from_blob: construct aDocfrom a Git blob by deserializing its contents.
Implementations§
Source§impl Doc
impl Doc
Sourcepub fn initial(project: Project, delegate: Did, visibility: Visibility) -> Doc
pub fn initial(project: Project, delegate: Did, visibility: Visibility) -> Doc
Construct the initial Doc for an identity.
It will begin with the provided project in the Doc::payload, the
delegate as the sole delegate, a threshold of 1, and the given
visibility.
Sourcepub fn from_blob(blob: &Blob<'_>) -> Result<Doc, DocError>
pub fn from_blob(blob: &Blob<'_>) -> Result<Doc, DocError>
Construct a Doc contained in the provided Git blob.
Sourcepub fn with_edits<F>(self, f: F) -> Result<Doc, DocError>
pub fn with_edits<F>(self, f: F) -> Result<Doc, DocError>
Using the current state of the Doc, perform any edits on the RawDoc
form and verify the changes.
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.
pub fn default_branch_rule( &self, ) -> Result<(Pattern, Rule<ResolvedDelegates, Threshold>), DefaultBranchRuleError>
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) -> &NonZero<usize>
pub fn threshold_nonzero(&self) -> &NonZero<usize>
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<'de> Deserialize<'de> for Doc
impl<'de> Deserialize<'de> for Doc
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Doc, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Doc, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl GetCanonicalRefs for Doc
impl GetCanonicalRefs for Doc
type Error = CanonicalRefsError
Source§fn canonical_refs(
&self,
) -> Result<Option<CanonicalRefs>, <Doc as GetCanonicalRefs>::Error>
fn canonical_refs( &self, ) -> Result<Option<CanonicalRefs>, <Doc as GetCanonicalRefs>::Error>
CanonicalRefs, returning Some if they are not
present, and None if they are missing. Read moreSource§fn raw_canonical_refs(
&self,
) -> Result<Option<RawCanonicalRefs>, <Doc as GetCanonicalRefs>::Error>
fn raw_canonical_refs( &self, ) -> Result<Option<RawCanonicalRefs>, <Doc as GetCanonicalRefs>::Error>
RawCanonicalRefs, returning Some if they are not
present, and None if they are missing. Read moreSource§fn canonical_refs_or_default<D, E>(
&self,
default: D,
) -> Result<CanonicalRefs, E>
fn canonical_refs_or_default<D, E>( &self, default: D, ) -> Result<CanonicalRefs, E>
CanonicalRefs, and in the case of None, then use the
default function to return a default set of CanonicalRefs.Source§impl Serialize for Doc
impl Serialize for Doc
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Doc
impl StructuralPartialEq for Doc
Auto Trait Implementations§
impl Freeze for Doc
impl RefUnwindSafe for Doc
impl Send for Doc
impl Sync for Doc
impl Unpin for Doc
impl UnwindSafe for Doc
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more