pub struct Context {
pub request: Request,
pub response: Response,
pub route_params: RouteParams,
pub attributes: ThreadSafeAttributeStore,
}Expand description
Represents the internal state of the application context.
This structure holds all the data associated with a single request-response cycle, including the request, response, and any custom attributes.
Fields§
§request: RequestThe incoming HTTP request.
response: ResponseThe outgoing HTTP response.
route_params: RouteParamsParameters extracted from the route path.
attributes: ThreadSafeAttributeStoreA collection of custom attributes for sharing data within the request lifecycle.
Implementations§
Source§impl Context
Implementation of methods for Context structure.
impl Context
Implementation of methods for Context structure.
Sourcepub fn try_get_route_param<T>(&self, name: T) -> Option<String>
pub fn try_get_route_param<T>(&self, name: T) -> Option<String>
Sourcepub fn get_route_param<T>(&self, name: T) -> String
pub fn get_route_param<T>(&self, name: T) -> String
Sourcepub fn try_get_attribute<V, K>(&self, key: K) -> Option<V>
pub fn try_get_attribute<V, K>(&self, key: K) -> Option<V>
Sourcepub fn get_attribute<V, K>(&self, key: K) -> V
pub fn get_attribute<V, K>(&self, key: K) -> V
Sourcepub fn set_attribute<K, V>(&mut self, key: K, value: V) -> &mut Self
pub fn set_attribute<K, V>(&mut self, key: K, value: V) -> &mut Self
Sourcepub fn remove_attribute<K>(&mut self, key: K) -> &mut Self
pub fn remove_attribute<K>(&mut self, key: K) -> &mut Self
Sourcepub fn clear_attribute(&mut self) -> &mut Self
pub fn clear_attribute(&mut self) -> &mut Self
Sourcepub fn set_task_panic(&mut self, panic_data: PanicData) -> &mut Self
pub fn set_task_panic(&mut self, panic_data: PanicData) -> &mut Self
Sourcepub fn try_get_task_panic_data(&self) -> Option<PanicData>
pub fn try_get_task_panic_data(&self) -> Option<PanicData>
Retrieves panic data associated with the current task.
§Returns
Option<PanicData>- Task panic data if a panic was caught during execution.
Sourcepub fn get_task_panic_data(&self) -> PanicData
pub fn get_task_panic_data(&self) -> PanicData
Sourcepub fn try_get_request_error_data(&self) -> Option<RequestError>
pub fn try_get_request_error_data(&self) -> Option<RequestError>
Retrieves request error information if an error occurred during handling.
§Returns
Option<RequestError>- The request error information if an error was caught.
Sourcepub fn get_request_error_data(&self) -> RequestError
pub fn get_request_error_data(&self) -> RequestError
Source§impl Context
impl Context
pub fn get_request(&self) -> &Request
pub fn get_mut_request(&mut self) -> &mut Request
pub fn set_request(&mut self, val: Request) -> &mut Self
pub fn get_response(&self) -> &Response
pub fn get_mut_response(&mut self) -> &mut Response
pub fn set_response(&mut self, val: Response) -> &mut Self
pub fn get_route_params(&self) -> &RouteParams
pub fn get_mut_route_params(&mut self) -> &mut RouteParams
pub fn set_route_params(&mut self, val: RouteParams) -> &mut Self
pub fn get_attributes(&self) -> &ThreadSafeAttributeStore
pub fn get_mut_attributes(&mut self) -> &mut ThreadSafeAttributeStore
pub fn set_attributes(&mut self, val: ThreadSafeAttributeStore) -> &mut Self
Trait Implementations§
impl Eq for Context
Implementation of Eq trait for Context.
Source§impl From<&Context> for usize
Implementation of From trait for converting &Context into usize address.
impl From<&Context> for usize
Implementation of From trait for converting &Context into usize address.
Source§impl From<&mut Context> for usize
Implementation of From trait for converting &mut Context into usize address.
impl From<&mut Context> for usize
Implementation of From trait for converting &mut Context into usize address.
Source§impl From<usize> for &'static Context
Implementation of From trait for converting usize address into &Context.
impl From<usize> for &'static Context
Implementation of From trait for converting usize address into &Context.
Source§fn from(address: usize) -> &'static Context
fn from(address: usize) -> &'static Context
Converts a memory address into a reference to Context.
§Arguments
usize- The memory address of theContextinstance.
§Returns
&'static Context- A reference to theContextat the given address.
§Safety
- The address is guaranteed to be a valid
Contextinstance that was previously converted from a reference and is managed by the runtime.
Source§impl<'a> From<usize> for &'a mut Context
Implementation of From trait for converting usize address into &mut Context.
impl<'a> From<usize> for &'a mut Context
Implementation of From trait for converting usize address into &mut Context.
Source§fn from(address: usize) -> &'a mut Context
fn from(address: usize) -> &'a mut Context
Converts a memory address into a mutable reference to Context.
§Arguments
usize- The memory address of theContextinstance.
§Returns
&'a mut Context- A mutable reference to theContextat the given address.
§Safety
- The address is guaranteed to be a valid
Contextinstance that was previously converted from a reference and is managed by the runtime.
Source§impl Lifetime for Context
Implementation of Lifetime trait for Context.
impl Lifetime for Context
Implementation of Lifetime trait for Context.
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.