[][src]Struct dsf_core::wire::container::Container

pub struct Container<T: ImmutableData> { /* fields omitted */ }

Container object provides base field accessors over an arbitrary (mutable or immutable) buffers See https://lab.whitequark.org/notes/2016-12-13/abstracting-over-mutability-in-rust/ for details

Implementations

impl<'a, T: ImmutableData> Container<T>[src]

pub fn from(buff: T) -> (Self, usize)[src]

Create a new container object from an existing buffer This parses the header and splits the data into fields to simplify access

pub fn header(&self) -> WireHeader<&[u8]>[src]

Fetch wire header

pub fn id(&self) -> &[u8][src]

Fetch object ID

pub fn body(&self) -> &[u8][src]

Return the body of data

pub fn private_options(&self) -> &[u8][src]

Return the private options section data

pub fn public_options(&self) -> impl Iterator<Item = Options> + '_[src]

Return the public options section data

pub fn signed(&self) -> &[u8][src]

Return the signed portion of the message for signing or verification

pub fn signature(&self) -> &[u8][src]

Return the signature portion of the message for verification

pub fn len(&self) -> usize[src]

Return the total length of the object (from the header)

pub fn verify<V, E>(&self, verifier: V) -> Result<bool, E> where
    V: FnMut(&Id, &Signature, &[u8]) -> Result<bool, E>, 
[src]

Verify the contents of a given container This calls the provided verifier with the id, body, and signature and forwards the result to the caller

pub fn raw(&self) -> &[u8][src]

Fetch the raw data using internal header length

impl<'a, T: AsRef<[u8]>> Container<T>[src]

pub fn parse<P, S>(
    data: T,
    pub_key_s: P,
    sec_key_s: S
) -> Result<(Base, usize), BaseError> where
    P: FnMut(&Id) -> Option<PublicKey>,
    S: FnMut(&Id) -> Option<SecretKey>, 
[src]

Parses a data array into a base object using the pub_key and sec_key functions to locate keys for validation and decyption

impl<'a, T: AsRef<[u8]> + AsMut<[u8]>> Container<T>[src]

pub fn encode(
    buff: T,
    base: &Base,
    signing_key: &PrivateKey,
    encryption_key: Option<&SecretKey>
) -> (Self, usize)
[src]

Trait Implementations

impl<T: Clone + ImmutableData> Clone for Container<T>[src]

impl<T: Debug + ImmutableData> Debug for Container<T>[src]

impl<T: PartialEq + ImmutableData> PartialEq<Container<T>> for Container<T>[src]

impl<T: ImmutableData> StructuralPartialEq for Container<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Container<T> where
    T: RefUnwindSafe

impl<T> Send for Container<T> where
    T: Send

impl<T> Sync for Container<T> where
    T: Sync

impl<T> Unpin for Container<T> where
    T: Unpin

impl<T> UnwindSafe for Container<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.