Skip to main content

ContextData

Struct ContextData 

Source
pub struct ContextData {
    pub aborted: bool,
    pub socket: Option<ArcRwLockUdpSocket>,
    pub request: Request,
    pub response: Response,
    pub client_addr: Option<SocketAddr>,
    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 socket, request, response, and any custom attributes.

Accessors are generated by #[derive(Data)]; Copy fields return values and the optional socket returns an owned Option clone via type(...) hints.

Fields§

§aborted: bool

A flag indicating whether the request handling has been aborted.

§socket: Option<ArcRwLockUdpSocket>

The underlying network socket for the connection.

§request: Request

The incoming UDP request data.

§response: Response

The outgoing UDP response data.

§client_addr: Option<SocketAddr>

The client’s socket address.

§attributes: ThreadSafeAttributeStore

A collection of custom attributes for sharing data within the request lifecycle.

Implementations§

Source§

impl ContextData

Implementation of methods for ContextData.

Source

pub fn new( socket: ArcRwLockUdpSocket, request: Request, client_addr: SocketAddr, ) -> Self

Creates a new ContextData with the given socket, request, and client address.

§Arguments
  • ArcRwLockUdpSocket - The network socket.
  • Request - The request data.
  • SocketAddr - The client’s socket address.
§Returns
  • Self - A new ContextData instance.
Source§

impl ContextData

Source

pub fn get_aborted(&self) -> bool

Source

pub fn get_mut_aborted(&mut self) -> &mut bool

Source

pub fn set_aborted(&mut self, val: bool) -> &mut Self

Source

pub fn get_socket(&self) -> Option<ArcRwLockUdpSocket>

Source

pub fn try_get_socket(&self) -> Option<ArcRwLockUdpSocket>

Source

pub fn get_mut_socket(&mut self) -> &mut Option<ArcRwLockUdpSocket>

Source

pub fn set_socket(&mut self, val: Option<ArcRwLockUdpSocket>) -> &mut Self

Source

pub fn get_request(&self) -> &Request

Source

pub fn get_mut_request(&mut self) -> &mut Request

Source

pub fn set_request(&mut self, val: Request) -> &mut Self

Source

pub fn get_response(&self) -> &Response

Source

pub fn get_mut_response(&mut self) -> &mut Response

Source

pub fn set_response(&mut self, val: Response) -> &mut Self

Source

pub fn get_client_addr(&self) -> Option<SocketAddr>

Source

pub fn try_get_client_addr(&self) -> Option<SocketAddr>

Source

pub fn get_mut_client_addr(&mut self) -> &mut Option<SocketAddr>

Source

pub fn set_client_addr(&mut self, val: Option<SocketAddr>) -> &mut Self

Source

pub fn get_attributes(&self) -> &ThreadSafeAttributeStore

Source

pub fn get_mut_attributes(&mut self) -> &mut ThreadSafeAttributeStore

Source

pub fn set_attributes(&mut self, val: ThreadSafeAttributeStore) -> &mut Self

Trait Implementations§

Source§

impl Clone for ContextData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ContextData

Provides a default implementation for ContextData.

Source§

fn default() -> Self

Creates a default ContextData with empty values.

§Returns
  • Self - A new instance with default values.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.