Trait biscuit::CompactPart

source ·
pub trait CompactPart {
    // Required methods
    fn to_bytes(&self) -> Result<Vec<u8>, Error>;
    fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
       where Self: Sized;

    // Provided methods
    fn from_base64<B: AsRef<[u8]>>(encoded: &B) -> Result<Self, Error>
       where Self: Sized { ... }
    fn to_base64(&self) -> Result<Base64Url, Error> { ... }
}
Expand description

A “part” of the compact representation of JWT/JWS/JWE. Parts are first serialized to some form and then base64 encoded and separated by periods.

An automatic implementation for any T that implements the marker trait CompactJson is provided. This implementation will serialize/deserialize T to JSON via serde.

Required Methods§

source

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Convert this part into bytes

source

fn from_bytes(bytes: &[u8]) -> Result<Self, Error>where Self: Sized,

Convert a sequence of bytes into Self

Provided Methods§

source

fn from_base64<B: AsRef<[u8]>>(encoded: &B) -> Result<Self, Error>where Self: Sized,

Base64 decode into Self

source

fn to_base64(&self) -> Result<Base64Url, Error>

Serialize Self to some form and then base64URL Encode

Implementations on Foreign Types§

source§

impl CompactPart for Vec<u8>

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, Error>

Convert a sequence of bytes into Self

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Implementors§

source§

impl CompactPart for Base64Url

source§

impl<T> CompactPart for Twhere T: CompactJson,

source§

impl<T: CompactPart, H: Serialize + DeserializeOwned> CompactPart for Compact<T, H>

Implementation for embedded inside a JWE.