Struct RawDoc

Source
pub struct RawDoc {
    pub payload: BTreeMap<PayloadId, Payload>,
    pub delegates: Vec<Did>,
    pub threshold: usize,
    pub visibility: Visibility,
    /* private fields */
}
Expand description

RawDoc is similar to the Doc type, however, it can be edited and may not be valid.

It is expected that any changes to a Doc are made via RawDoc, and then verified by using RawDoc::verified.

Note that RawDoc only implements Deserialize. This prevents us from serializing an unverified document, while also making sure that any document that is deserialized is verified.

Fields§

§payload: BTreeMap<PayloadId, Payload>

The payload section.

§delegates: Vec<Did>

The delegates section.

§threshold: usize

The signature threshold.

§visibility: Visibility

Repository visibility.

Implementations§

Source§

impl RawDoc

Source

pub fn new( project: Project, delegates: Vec<Did>, threshold: usize, visibility: Visibility, ) -> RawDoc

Construct a new RawDoc with an initial RawDoc::payload containing the provided Project, and the given delegates, threshold, and visibility.

Source

pub fn version(&self) -> &Version

Get the version of the document.

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 is_delegate(&self, did: &Did) -> bool

Check if the given did is in the set of RawDoc::delegates.

Source

pub fn delegate(&mut self, did: Did)

Add a new delegate to the document.

Note that if this Did is a duplicate, then the resulting set will only show it once.

Source

pub fn rescind(&mut self, did: &Did) -> Result<bool, DocError>

Remove the did from the set of delegates. Returns true if it was removed.

Source

pub fn from_json(bytes: &[u8]) -> Result<RawDoc, DocError>

Construct the RawDoc from the set of bytes that are expected to be in JSON format.

Source

pub fn verified(self) -> Result<Doc, DocError>

Verify the RawDoc’s values, converting it into a valid Doc.

The verifications are as follows:

Trait Implementations§

Source§

impl Clone for RawDoc

Source§

fn clone(&self) -> RawDoc

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 Debug for RawDoc

Source§

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

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

impl<'de> Deserialize<'de> for RawDoc

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<RawDoc, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl GetCanonicalRefs for RawDoc

Source§

type Error = CanonicalRefsError

Source§

fn canonical_refs( &self, ) -> Result<Option<CanonicalRefs>, <RawDoc as GetCanonicalRefs>::Error>

Retrieve the CanonicalRefs, returning Some if they are not present, and None if they are missing. Read more
Source§

fn raw_canonical_refs( &self, ) -> Result<Option<RawCanonicalRefs>, <RawDoc as GetCanonicalRefs>::Error>

Retrieve the RawCanonicalRefs, returning Some if they are not present, and None if they are missing. Read more
Source§

fn canonical_refs_or_default<D, E>( &self, default: D, ) -> Result<CanonicalRefs, E>
where D: Fn() -> Result<CanonicalRefs, E>, E: From<Self::Error>,

Retrieve the CanonicalRefs, and in the case of None, then use the default function to return a default set of CanonicalRefs.
Source§

impl PartialEq for RawDoc

Source§

fn eq(&self, other: &RawDoc) -> 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 TryFrom<RawDoc> for Doc

Source§

type Error = DocError

The type returned in the event of a conversion error.
Source§

fn try_from(doc: RawDoc) -> Result<Doc, <Doc as TryFrom<RawDoc>>::Error>

Performs the conversion.
Source§

impl Eq for RawDoc

Source§

impl StructuralPartialEq for RawDoc

Auto Trait Implementations§

§

impl Freeze for RawDoc

§

impl RefUnwindSafe for RawDoc

§

impl Send for RawDoc

§

impl Sync for RawDoc

§

impl Unpin for RawDoc

§

impl UnwindSafe for RawDoc

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<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<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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoInit<ZeroInit> for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,