TrustSchema

Struct TrustSchema 

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

A collection of trust schema rules, optionally backed by an imported LightVerSec model.

§Backing stores

A TrustSchema combines two independent rule sources, OR’d together:

  1. A vector of native SchemaRules authored in ndn-rs’s own text grammar (data_pattern => key_pattern). Convenient for simple hand-written policies.
  2. An optional compiled LvsModel imported via TrustSchema::from_lvs_binary from the binary TLV format used by python-ndn, NDNts, and ndnd. Lets ndn-rs consume trust schemas authored in the wider NDN community’s tooling.

TrustSchema::allows returns true if either source permits the (data_name, key_name) pair — you can mix a hand-written rule with an imported LVS model and both will be consulted.

Implementations§

Source§

impl TrustSchema

Source

pub fn new() -> Self

Source

pub fn add_rule(&mut self, rule: SchemaRule)

Source

pub fn from_lvs_binary(wire: &[u8]) -> Result<Self, LvsError>

Construct a trust schema backed by a compiled LightVerSec model in its TLV binary format.

The binary format is defined at https://python-ndn.readthedocs.io/en/latest/src/lvs/binary-format.html and produced by python-ndn’s LVS compiler, NDNts @ndn/lvs, and ndnd. See the crate::lvs module docs for the supported feature subset — notably, user functions ($eq, $regex, …) are parsed but not dispatched in v0.1.0, so any rule that depends on one will never match a packet. Inspect LvsModel::uses_user_functions on the result of TrustSchema::lvs_model if you need to refuse such schemas.

The resulting schema has no native SchemaRules — add them with TrustSchema::add_rule if you want to mix the two sources.

Source

pub fn lvs_model(&self) -> Option<&LvsModel>

Return the imported LVS model, if this schema was constructed from one. Use this to inspect LvsModel::uses_user_functions or walk the node graph for diagnostics.

Source

pub fn allows(&self, data_name: &Name, key_name: &Name) -> bool

Returns true if at least one source permits this (data_name, key_name) pair. Checks native rules first (cheap), then falls through to the LVS model if present.

Source

pub fn rules(&self) -> &[SchemaRule]

Return an immutable slice of all native rules in this schema. Does not include rules inside an imported LVS model.

Source

pub fn remove_rule(&mut self, index: usize) -> SchemaRule

Remove the rule at index, returning it.

Panics if index is out of bounds.

Source

pub fn clear(&mut self)

Remove all rules, returning the schema to its empty (reject-all) state. Also clears any imported LVS model.

Source

pub fn accept_all() -> Self

Accept any signed packet regardless of name relationship.

Useful for the AcceptSigned security profile and for tests.

Source

pub fn hierarchical() -> Self

Hierarchical trust: data and key must share a common first component.

Rule: /<org>/** must be signed by /<org>/**. The actual hierarchy is enforced by the certificate chain walk — a key can only be trusted if its cert was issued by a parent key, all the way up to a trust anchor. The schema just ensures the top-level namespace matches.

Trait Implementations§

Source§

impl Clone for TrustSchema

Source§

fn clone(&self) -> TrustSchema

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 TrustSchema

Source§

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

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

impl Default for TrustSchema

Source§

fn default() -> TrustSchema

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V