[][src]Struct hancock::Signature

pub struct Signature<'a> { /* fields omitted */ }

A parsed or generated Signature.

Implementations

impl<'a> Signature<'a>[src]

pub fn create<E: Debug>(
    key_id: &'a str,
    request_method: &Method,
    request_path_and_query: &str,
    lifetime_secs: u64,
    headers: &HeaderMap,
    sign: impl FnOnce(Vec<u8>) -> Result<Vec<u8>, E>
) -> Result<Self, SignError<E>>
[src]

Construct a signature.

All headers in headers will be included, as well as (request-target), (created), and (expires) (based on lifetime_secs parameter)

The passed sign will be called with the body to sign.

pub fn create_legacy<E: Debug>(
    key_id: &'a str,
    request_method: &Method,
    request_path_and_query: &str,
    headers: &HeaderMap,
    sign: impl FnOnce(Vec<u8>) -> Result<Vec<u8>, E>
) -> Result<Self, SignError<E>>
[src]

Create an old-style signature (no (created) and (expires))

Panics

Panics if headers doesn't contain a Date header

pub fn parse(value: &'a HeaderValue) -> Result<Self, ParseError>[src]

Parse a Signature header

pub fn to_header(&self) -> HeaderValue[src]

Create a Signature header value for the signature.

pub fn verify<E: Debug>(
    &self,
    request_method: &Method,
    request_path_and_query: &str,
    headers: &HeaderMap,
    verify: impl FnOnce(&[u8], &[u8]) -> Result<bool, E>
) -> Result<bool, VerifyError<E>>
[src]

Verify the signature for a given request target and HeaderMap.

The passed verify function will be called with (body, signature) where body is the body that should match the signature.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Signature<'a>

impl<'a> Send for Signature<'a>

impl<'a> Sync for Signature<'a>

impl<'a> Unpin for Signature<'a>

impl<'a> UnwindSafe for Signature<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.