1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use super::AuthenticationError;
use crate::headers::www_authenticate::Challenge;

/// Trait implemented for types that provides configuration for the authentication
/// [extractors](super::AuthExtractor).
pub trait AuthExtractorConfig {
    /// Associated challenge type.
    type Inner: Challenge;

    /// Convert the config instance into a HTTP challenge.
    fn into_inner(self) -> Self::Inner;
}

impl<T> From<T> for AuthenticationError<<T as AuthExtractorConfig>::Inner>
where
    T: AuthExtractorConfig,
{
    fn from(config: T) -> Self {
        AuthenticationError::new(config.into_inner())
    }
}