Context

Struct Context 

Source
pub struct Context(/* private fields */);
Expand description

Thread-safe context wrapper for UDP operations.

Provides synchronized access to the inner context.

Implementations§

Source§

impl Context

Implementation of Context methods.

Provides thread-safe operations on the UDP context.

Source

pub async fn get_read_lock(&self) -> RwLockReadContext<'_>

Acquires a read lock on the inner context.

§Returns
  • RwLockReadContext - Read guard for the inner context.
Source

pub async fn get_write_lock(&self) -> RwLockWriteContext<'_>

Acquires a write lock on the inner context.

§Returns
  • RwLockWriteContext - Write guard for the inner context.
Source

pub async fn get(&self) -> InnerContext

Gets a clone of the inner context.

§Returns
  • InnerContext - Clone of the inner context.
Source

pub async fn get_request(&self) -> Request

Gets the request data from the context.

§Returns
  • Request - Clone of the request data.
Source

pub async fn get_response(&self) -> Response

Gets the response data from the context.

§Returns
  • Response - Clone of the response data.
Source

pub async fn get_socket(&self) -> OptionArcRwLockUdpSocket

Gets the UDP socket from the context.

§Returns
  • OptionArcRwLockUdpSocket - Clone of the socket if present.
Source

pub async fn get_socket_addr(&self) -> OptionSocketAddr

Gets the socket address from the context.

§Returns
  • OptionSocketAddr - Clone of the socket address if present.
Source

pub async fn get_socket_addr_or_default(&self) -> SocketAddr

Gets the socket address or default if not present.

§Returns
  • SocketAddr - Socket address or default (0.0.0.0:0).
Source

pub async fn get_socket_addr_string(&self) -> Option<String>

Gets the socket address as a string.

§Returns
  • Option<String> - Socket address string if present.
Source

pub async fn get_socket_addr_or_default_string(&self) -> String

Gets the socket address or default as a string.

§Returns
  • String - Socket address string or default.
Source

pub async fn get_socket_host(&self) -> OptionSocketHost

Gets the socket host IP address.

§Returns
  • OptionSocketHost - Host IP address if present.
Source

pub async fn get_socket_port(&self) -> OptionSocketPort

Gets the socket port number.

§Returns
  • OptionSocketPort - Port number if present.
Source

pub async fn send<T: Into<ResponseData>>(&self, data: T) -> ResponseResult

Sends response data through the socket.

§Arguments
  • T - Data convertible to ResponseData.
§Returns
  • ResponseResult - Result of the send operation.
Source

pub async fn set_data_value<T: Any + Send + Sync + Clone>( &self, key: &str, value: &T, ) -> &Self

Sets a value in the context data storage.

§Arguments
  • &str - Key for the value.
  • &T - Value to store (must be Any + Send + Sync + Clone).
§Returns
  • &Self - Reference to self for chaining.
Source

pub async fn get_data_value<T: Any + Send + Sync + Clone>( &self, key: &str, ) -> Option<T>

Gets a value from the context data storage.

§Arguments
  • &str - Key for the value.
§Returns
  • Option<T> - Retrieved value if present and of correct type.
Source

pub async fn remove_data_value(&self, key: &str) -> &Self

Removes a value from the context data storage.

§Arguments
  • &str - Key for the value to remove.
§Returns
  • &Self - Reference to self for chaining.
Source

pub async fn clear_data(&self) -> &Self

Clears all data from the context data storage.

§Returns
  • &Self - Reference to self for chaining.

Trait Implementations§

Source§

impl Clone for Context

Source§

fn clone(&self) -> Context

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.