AuthScheme

Trait AuthScheme 

Source
pub trait AuthScheme: Sized {
    type Input<'a>;
    type AddAuthenticationError: Into<Box<dyn Error + Sync + Send>>;
    type Output;
    type ExtractAuthenticationError: Into<Box<dyn Error + Sync + Send>>;

    // Required methods
    fn add_authentication<T>(
        request: &mut Request<T>,
        input: Self::Input<'_>,
    ) -> Result<(), Self::AddAuthenticationError>
       where T: AsRef<[u8]>;
    fn extract_authentication<T>(
        request: &Request<T>,
    ) -> Result<Self::Output, Self::ExtractAuthenticationError>
       where T: AsRef<[u8]>;
}
Available on crate feature api only.
Expand description

Trait implemented by types representing an authentication scheme used by an endpoint.

Required Associated Types§

Source

type Input<'a>

The input necessary to generate the authentication.

Source

type AddAuthenticationError: Into<Box<dyn Error + Sync + Send>>

The error type returned from add_authentication().

Source

type Output

The authentication data that can be extracted from a request.

Source

type ExtractAuthenticationError: Into<Box<dyn Error + Sync + Send>>

The error type returned from extract_authentication().

Required Methods§

Source

fn add_authentication<T>( request: &mut Request<T>, input: Self::Input<'_>, ) -> Result<(), Self::AddAuthenticationError>
where T: AsRef<[u8]>,

Add this authentication scheme to the given outgoing request, if necessary.

Returns an error if the endpoint requires authentication but the input doesn’t provide it, or if the input fails to serialize to the proper format.

Source

fn extract_authentication<T>( request: &Request<T>, ) -> Result<Self::Output, Self::ExtractAuthenticationError>
where T: AsRef<[u8]>,

Extract the data of this authentication scheme from the given incoming request.

Returns an error if the endpoint requires authentication but the request doesn’t provide it, or if the output fails to deserialize to the proper format.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§