Struct IdCred

Source
#[repr(C)]
pub struct IdCred { pub bytes: BufferIdCred, }
Expand description

A value of ID_CRED_x: a credential identifier.

Possible values include key IDs, credentials by value and others.

let short_kid = IdCred::from_encoded_value(&hex!("17")).unwrap(); // 23
assert_eq!(short_kid.as_full_value(), &hex!("a1044117")); // {4: h'17'}
let long_kid = IdCred::from_encoded_value(&hex!("43616263")).unwrap(); // 'abc'
assert_eq!(long_kid.as_full_value(), &hex!("a10443616263")); // {4: 'abc'}

Fields§

§bytes: BufferIdCred

The value is always stored in the ID_CRED_x form as a serialized one-element dictionary; while this technically wastes two bytes, it has the convenient property of having the full value available as a slice.

Implementations§

Source§

impl IdCred

Source

pub fn new() -> Self

Source

pub fn from_full_value(value: &[u8]) -> Result<Self, EDHOCError>

Source

pub fn from_encoded_value(value: &[u8]) -> Result<Self, EDHOCError>

Instantiate an IdCred from an encoded value.

Source

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

View the full value of the ID_CRED_x: the CBOR encoding of a 1-element CBOR map

This is the value that is used when ID_CRED_x has no impact on message size, see RFC 9528 Section 3.5.3.2.

Source

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

View the value as encoded in the ID_CRED_x position of plaintext_2 and plaintext_3.

Note that this is NOT doing CBOR encoding, it is rather performing (when applicable) the compact encoding of ID_CRED fields. This style of encoding is used when ID_CRED_x has an impact on message size.

Source

pub fn reference_only(&self) -> bool

Source

pub fn item_type(&self) -> IdCredType

Source

pub fn get_ccs(&self) -> Option<Credential>

Trait Implementations§

Source§

impl Clone for IdCred

Source§

fn clone(&self) -> IdCred

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 Debug for IdCred

Source§

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

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

impl Default for IdCred

Source§

fn default() -> IdCred

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

impl PartialEq for IdCred

Source§

fn eq(&self, other: &IdCred) -> 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 Copy for IdCred

Source§

impl StructuralPartialEq for IdCred

Auto Trait Implementations§

§

impl Freeze for IdCred

§

impl RefUnwindSafe for IdCred

§

impl Send for IdCred

§

impl Sync for IdCred

§

impl Unpin for IdCred

§

impl UnwindSafe for IdCred

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