Struct activitypub_federation::config::Data
source · pub struct Data<T: Clone> { /* private fields */ }
Expand description
Stores data for handling one specific HTTP request.
It gives acess to the app_data
which was passed to FederationConfig::builder.
Additionally it contains a counter for outgoing HTTP requests. This is necessary to prevent denial of service attacks, where an attacker triggers fetching of recursive objects.
https://www.w3.org/TR/activitypub/#security-recursive-objects
Implementations§
source§impl<T: Clone> Data<T>
impl<T: Clone> Data<T>
sourcepub fn app_data(&self) -> &T
pub fn app_data(&self) -> &T
Returns the data which was stored in FederationConfigBuilder::app_data
sourcepub fn domain(&self) -> &str
pub fn domain(&self) -> &str
The domain that was configured in FederationConfig.
sourcepub fn reset_request_count(&self) -> Self
pub fn reset_request_count(&self) -> Self
Returns a new instance of Data
with request counter set to 0.
sourcepub fn request_count(&self) -> u32
pub fn request_count(&self) -> u32
Total number of outgoing HTTP requests made with this data.
Trait Implementations§
source§impl<T: Clone + 'static> FromRequest for Data<T>
impl<T: Clone + 'static> FromRequest for Data<T>
§type Future = Ready<Result<Data<T>, <Data<T> as FromRequest>::Error>>
type Future = Ready<Result<Data<T>, <Data<T> as FromRequest>::Error>>
Future that resolves to a
Self
. Read moresource§fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future
fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future
Create a
Self
from request parts asynchronously.source§impl<S, T> FromRequestParts<S> for Data<T>
impl<S, T> FromRequestParts<S> for Data<T>
§type Rejection = (StatusCode, &'static str)
type Rejection = (StatusCode, &'static str)
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Auto Trait Implementations§
impl<T> !Freeze for Data<T>
impl<T> !RefUnwindSafe for Data<T>
impl<T> Send for Data<T>where
T: Send,
impl<T> Sync for Data<T>where
T: Sync,
impl<T> Unpin for Data<T>where
T: Unpin,
impl<T> !UnwindSafe for Data<T>
Blanket Implementations§
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
source§impl<S, B, T> FromRequest<S, B, ViaParts> for T
impl<S, B, T> FromRequest<S, B, ViaParts> for T
§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
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