[−][src]Struct actix_web::web::RouteData
Route data.
Route data is an arbitrary data attached to specific route.
Route data could be added to route during route configuration process
with Route::data()
method. Route data is also used as an extractor
configuration storage. Route data could be accessed in handler
via RouteData<T>
extractor.
If route data is not set for a handler, using RouteData
extractor
would cause Internal Server Error response.
use actix_web::{web, App}; struct MyData { counter: Cell<usize>, } /// Use `RouteData<T>` extractor to access data in handler. fn index(data: web::RouteData<MyData>) { data.counter.set(data.counter.get() + 1); } fn main() { let app = App::new().service( web::resource("/index.html").route( web::get() // Store `MyData` in route storage .data(MyData{ counter: Cell::new(0) }) // Route data could be used as extractor configuration storage, // limit size of the payload .data(web::PayloadConfig::new(4096)) // register handler .to(index) )); }
Methods
impl<T> RouteData<T>
[src]
Trait Implementations
impl<T: 'static, P> FromRequest<P> for RouteData<T>
[src]
type Error = Error
The associated error which can be returned.
type Future = Result<Self, Error>
Future that resolves to a Self
fn from_request(req: &mut ServiceFromRequest<P>) -> Self::Future
[src]
impl<T> Clone for RouteData<T>
[src]
fn clone(&self) -> RouteData<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Deref for RouteData<T>
[src]
Auto Trait Implementations
impl<T> Send for RouteData<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Sync for RouteData<T> where
T: Send + Sync,
T: Send + Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.