Struct Container

Source
pub struct Container<T: ImmutableData> { /* private fields */ }
Expand description

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§

Source§

impl<'a, T: ImmutableData> Container<T>

Source

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

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

Source

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

Fetch wire header

Source

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

Fetch object ID

Source

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

Return the body of data

Source

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

Return the private options section data

Source

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

Return the public options section data

Source

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

Return the signed portion of the message for signing or verification

Source

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

Return the signature portion of the message for verification

Source

pub fn len(&self) -> usize

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

Source

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

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

Source

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

Fetch the raw data using internal header length

Source§

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

Source

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>,

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

Source§

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

Source

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

Trait Implementations§

Source§

impl<T: Clone + ImmutableData> Clone for Container<T>

Source§

fn clone(&self) -> Container<T>

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<T: Debug + ImmutableData> Debug for Container<T>

Source§

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

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

impl<T: PartialEq + ImmutableData> PartialEq for Container<T>

Source§

fn eq(&self, other: &Container<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ImmutableData> StructuralPartialEq for Container<T>

Auto Trait Implementations§

§

impl<T> Freeze for Container<T>
where T: Freeze,

§

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§

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> 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.