Struct coset::HeaderBuilder

source ·
pub struct HeaderBuilder(_);
Expand description

Builder for Header objects.

Implementations§

source§

impl HeaderBuilder

source

pub fn new() -> Self

Constructor for builder.

source

pub fn build(self) -> Header

Build the completed object.

source

pub fn key_id(self, key_id: Vec<u8>) -> Self

Set the associated field.

source

pub fn algorithm(self, alg: Algorithm) -> Self

Set the algorithm.

source

pub fn add_critical(self, param: HeaderParameter) -> Self

Add a critical header.

source

pub fn add_critical_label(self, label: RegisteredLabel<HeaderParameter>) -> Self

Add a critical header.

source

pub fn content_format(self, content_type: CoapContentFormat) -> Self

Set the content type to a numeric value.

source

pub fn content_type(self, content_type: String) -> Self

Set the content type to a text value.

source

pub fn iv(self, iv: Vec<u8>) -> Self

Set the IV, and clear any partial IV already set.

source

pub fn partial_iv(self, iv: Vec<u8>) -> Self

Set the partial IV, and clear any IV already set.

source

pub fn add_counter_signature(self, sig: CoseSignature) -> Self

Add a counter signature.

source

pub fn value(self, label: i64, value: Value) -> Self

Set a header label:value pair. If duplicate labels are added to a Header, subsequent attempts to CBOR-encode the header will fail.

Panics

This function will panic if it used to set a header label from the range [1, 6].

source

pub fn text_value(self, label: String, value: Value) -> Self

Set a header label:value pair where the label is text.

Trait Implementations§

source§

impl Debug for HeaderBuilder

source§

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

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

impl Default for HeaderBuilder

source§

fn default() -> HeaderBuilder

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.