pub struct Context { /* private fields */ }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.
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>(&self, key: impl AsRef<str>) -> Option<V>where
V: AnySendSyncClone,
pub fn try_get_attribute<V>(&self, key: impl AsRef<str>) -> Option<V>where
V: AnySendSyncClone,
Sourcepub fn get_attribute<V>(&self, key: impl AsRef<str>) -> Vwhere
V: AnySendSyncClone,
pub fn get_attribute<V>(&self, key: impl AsRef<str>) -> Vwhere
V: AnySendSyncClone,
Retrieves a specific attribute by its key, casting it to the specified type, panicking if not found.
§Arguments
AsRef<str>- The key of the attribute to retrieve.
§Returns
AnySendSyncClone- The attribute value if it exists and can be cast to the specified type.
§Panics
- If the attribute is not found.
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 set_request(&mut self, val: Request) -> &mut Self
pub fn get_mut_request(&mut self) -> &mut Request
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 set_route_params(&mut self, val: RouteParams) -> &mut Self
pub fn get_route_params(&self) -> &RouteParams
pub fn get_mut_attributes(&mut self) -> &mut ThreadSafeAttributeStore
pub fn set_attributes(&mut self, val: ThreadSafeAttributeStore) -> &mut Self
pub fn get_attributes(&self) -> &ThreadSafeAttributeStore
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
&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.