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
impl Declarations
Sourcepub fn new() -> Declarations
pub fn new() -> Declarations
No declarations.
Sourcepub fn from_value(v: &Value) -> Result<Declarations>
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.
Sourcepub fn insert(&mut self, name: &str, entry: Declaration) -> Result<()>
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.
Sourcepub fn get(&self, name: &str) -> &[Declaration]
pub fn get(&self, name: &str) -> &[Declaration]
The entries for the function name (cell.ns + "/" + cell.fn); empty when none.
Sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
The declared function names, in ascending order.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &[Declaration])>
pub fn iter(&self) -> impl Iterator<Item = (&str, &[Declaration])>
Each declared name with its entries, names in ascending order.