Skip to main content

Declarations

Struct Declarations 

Source
pub struct Declarations { /* private fields */ }
Expand description

A publisher’s declarations (9.2, spec-0.4.3): per full function name (2.3), the dated entries naming the restricted licences the publisher permits as inputs of that function. Read from the key document of the host of the function’s namespace (KeyDocument). Names are kept in ascending order; each name’s entries in document order.

Implementations§

Source§

impl Declarations

Source

pub fn new() -> Declarations

No declarations.

Source

pub fn from_value(v: &Value) -> Result<Declarations>

Declarations from the JSON value of a declarations member: an object of at most 64 full function names, each to an array of 1 to 16 entries with exactly licence, valid_from and optionally valid_to, all strings, checked as in 9.2 (E_KEY_DOC). Two rules are the key document’s and not checked here, because the value alone cannot tell them: that every name is under the document’s host, and that the object is not empty ({} gives no declarations, as the licence vectors write none). KeyDocument::from_json checks both.

Source

pub fn insert(&mut self, name: &str, entry: Declaration) -> Result<()>

Adds an entry for the function name, a full function name (2.3), keeping the limits of 4.5 (64 names, 16 entries for one name). Every failure is E_KEY_DOC.

Source

pub fn get(&self, name: &str) -> &[Declaration]

The entries for the function name (cell.ns + "/" + cell.fn); empty when none.

Source

pub fn names(&self) -> impl Iterator<Item = &str>

The declared function names, in ascending order.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &[Declaration])>

Each declared name with its entries, names in ascending order.

Source

pub fn len(&self) -> usize

The number of declared names.

Source

pub fn is_empty(&self) -> bool

Whether nothing is declared.

Source

pub fn to_value(&self) -> Value

The JSON form of the declarations member (members in ascending name order).

Trait Implementations§

Source§

impl Clone for Declarations

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Declarations

Source§

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

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

impl Default for Declarations

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Declarations

Source§

impl Hash for Declarations

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Declarations

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Declarations

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<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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.