Skip to main content

MediaFrame

Struct MediaFrame 

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

A an abstraction of a media frame owning an internal buffer. Can optionally have meta data (e.g. a header) associated to it.

Implementations§

Source§

impl MediaFrame

Source

pub fn new<P>(frame_counter: &mut impl FrameCounter, payload: P) -> Self
where P: AsRef<[u8]>,

Creates a new media frame by copying the data of a payload buffer and assigning it the given frame count.

Source

pub fn with_meta_data<P, M>( frame_counter: &mut impl FrameCounter, payload: P, meta_data: M, ) -> Self
where P: AsRef<[u8]>, M: AsRef<[u8]>,

Creates a new media frame and assigns it the given frame count. Payload and meta data are copied into an internal buffer.

Source

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

Meta data associated with this media frame

Source

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

Payload of this media frame

Source

pub fn counter(&self) -> Counter

Frame count for the Sframe scheme associated to this media frame

Source

pub fn encrypt<A, D>(&self, key: &EncryptionKey<A, D>) -> Result<EncryptedFrame>
where A: AeadEncrypt<Secret = D::Secret>, D: KeyDerivation,

Encrypts the media frame with the sframe key according to RFC 9605 4.4.3. Dynamically allocates memory for the resulting EncryptedFrame. The associated meta data is not encrypted but considered for the authentication tag. Returns an crate::error::SframeError when encryption fails

Source

pub fn encrypt_into<'obuf, A, D>( &self, key: &EncryptionKey<A, D>, buffer: &'obuf mut impl FrameBuffer, ) -> Result<EncryptedFrameView<'obuf>>
where A: AeadEncrypt<Secret = D::Secret>, D: KeyDerivation,

Encrypts the media frame with the sframe key according to RFC 9605 4.4.3 and stores the result into the provided buffer. An EncryptedFrameView on the buffer is returned on success. The associated meta data is not encrypted but considered for the authentication tag. Returns an crate::error::SframeError when encryption fails.

Trait Implementations§

Source§

impl AsRef<[u8]> for MediaFrame

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for MediaFrame

Source§

fn clone(&self) -> MediaFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MediaFrame

Source§

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

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

impl Eq for MediaFrame

Source§

impl PartialEq for MediaFrame

Source§

fn eq(&self, other: &MediaFrame) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MediaFrame

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.

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.