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

pub struct Container<T: AsRef<[u8]>> { /* 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

Methods

impl<'a, T: AsRef<[u8]>> 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 protocol_version(&self) -> Kind[src]

pub fn application_id(&self) -> u16[src]

pub fn kind(&self) -> Kind[src]

pub fn flags(&self) -> Flags[src]

pub fn index(&self) -> u16[src]

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

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

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

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

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]

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]

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]

Encode a a higher level base object into a container using the provided buffer This encodes the base object into the buff and constructs a container from this encoded object

Trait Implementations

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

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

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

impl<T: AsRef<[u8]>> StructuralPartialEq for Container<T>[src]

Auto Trait Implementations

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

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

Blanket Implementations

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

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

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.

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

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

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