pub struct Rule<D, T> { /* private fields */ }Expand description
A Rule defines how a reference or set of references can be made canonical,
i.e. have a top-level refs/* entry – see Pattern.
The Rule::allowed type is generic to allow for Allowed to be used
for serialization and deserialization, however, the use of
Rule::validate should be used to get a valid rule.
The Rule::threshold, similarly, allows for doc::Threshold to be used, and
Rule::validate should be used to get a valid rule.
Implementations§
Source§impl Rule<Allowed, usize>
impl Rule<Allowed, usize>
Sourcepub fn validate<R>(
self,
resolve: &mut R,
) -> Result<Rule<ResolvedDelegates, Threshold>, ValidationError>
pub fn validate<R>( self, resolve: &mut R, ) -> Result<Rule<ResolvedDelegates, Threshold>, ValidationError>
Validate the Rule into a form that can be used for calculating
canonical references.
The resolve callback is to allow the caller to specify the DIDs of the
identity document, in the case that the allowed value is
Allowed::Delegates.
Source§impl Rule<ResolvedDelegates, Threshold>
impl Rule<ResolvedDelegates, Threshold>
Sourcepub fn default_branch(
did: Did,
name: &RefStr,
) -> Result<(Pattern, Rule<ResolvedDelegates, Threshold>), PatternError>
pub fn default_branch( did: Did, name: &RefStr, ) -> Result<(Pattern, Rule<ResolvedDelegates, Threshold>), PatternError>
Initialize a ValidRule for the default branch, given by name. The
rule will contain the single did as the allowed DID, and use a
threshold of 1.
Note that the serialization of the rule will use the delegates token
for the rule. E.g.
{
"pattern": "refs/heads/main",
"allow": ["did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi"],
"threshold": 1
}§Errors
If the name reference begins with refs/rad.
Source§impl<D, T> Rule<D, T>
impl<D, T> Rule<D, T>
Sourcepub fn new(allow: D, threshold: T) -> Rule<D, T>
pub fn new(allow: D, threshold: T) -> Rule<D, T>
Construct a new Rule with the given allow and threshold.
Sourcepub fn extensions(&self) -> &Map<String, Value>
pub fn extensions(&self) -> &Map<String, Value>
Get the extensions that may have been added to this Rule.
Sourcepub fn add_extensions(&mut self, extensions: impl Into<Map<String, Value>>)
pub fn add_extensions(&mut self, extensions: impl Into<Map<String, Value>>)
If the Rule::extensions is not set, the provided extensions will
be used.
Otherwise, it expects that the JSON value is a Map and the
extensions are merged. If the existing value is any other kind of JSON
value, this is a no-op.
Trait Implementations§
Source§impl<'de, D, T> Deserialize<'de> for Rule<D, T>where
D: Sealed + Deserialize<'de>,
T: Sealed + Deserialize<'de>,
impl<'de, D, T> Deserialize<'de> for Rule<D, T>where
D: Sealed + Deserialize<'de>,
T: Sealed + Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rule<D, T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rule<D, T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<D, T> Serialize for Rule<D, T>
impl<D, T> Serialize for Rule<D, T>
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<D, T> Eq for Rule<D, T>
impl<D, T> StructuralPartialEq for Rule<D, T>
Auto Trait Implementations§
impl<D, T> Freeze for Rule<D, T>
impl<D, T> RefUnwindSafe for Rule<D, T>where
D: RefUnwindSafe,
T: RefUnwindSafe,
impl<D, T> Send for Rule<D, T>
impl<D, T> Sync for Rule<D, T>
impl<D, T> Unpin for Rule<D, T>
impl<D, T> UnwindSafe for Rule<D, T>where
D: UnwindSafe,
T: UnwindSafe,
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