pub struct ApiState {
pub auth_framework: Arc<AuthFramework>,
pub rate_limiter: Arc<DistributedRateLimiter>,
pub authorization_service: Arc<AuthorizationService>,
pub email_verification_sender: Option<Arc<dyn EmailVerificationSender>>,
pub trusted_proxies: Vec<IpAddr>,
}Expand description
API server state
Fields§
§auth_framework: Arc<AuthFramework>§rate_limiter: Arc<DistributedRateLimiter>§email_verification_sender: Option<Arc<dyn EmailVerificationSender>>Delivers email-verification tokens to the address being verified. When None,
verification tokens are generated but nobody can receive them, so email
verification cannot complete (see email_verification).
trusted_proxies: Vec<IpAddr>Peer addresses of reverse proxies whose X-Forwarded-For the rate limiter may
believe. Empty by default: the connection’s peer address is the client.
Implementations§
Source§impl ApiState
impl ApiState
Sourcepub async fn new(auth_framework: Arc<AuthFramework>) -> Result<Self>
pub async fn new(auth_framework: Arc<AuthFramework>) -> Result<Self>
Create an ApiState wrapping the given AuthFramework.
A balanced distributed rate-limiter is initialised automatically.
§Example
ⓘ
let state = ApiState::new(Arc::new(auth_framework)).await?;Sourcepub fn with_email_verification_sender(
self,
sender: Arc<dyn EmailVerificationSender>,
) -> Self
pub fn with_email_verification_sender( self, sender: Arc<dyn EmailVerificationSender>, ) -> Self
Install the channel that delivers email-verification tokens to the address being verified (typically an SMTP or transactional-email integration).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ApiState
impl !UnwindSafe for ApiState
impl Forget for ApiState
impl Freeze for ApiState
impl Send for ApiState
impl Sync for ApiState
impl Unpin for ApiState
impl UnsafeUnpin for ApiState
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more