Skip to main content

VCLPool

Struct VCLPool 

Source
pub struct VCLPool { /* private fields */ }
Expand description

Manages multiple VCLConnections under a single pool.

Each connection gets a unique ConnectionId assigned at bind(). The pool enforces a maximum connection limit set at construction.

Implementations§

Source§

impl VCLPool

Source

pub fn new(max_connections: usize) -> Self

Create a new pool with a maximum number of concurrent connections.

§Example
use vcl_protocol::pool::VCLPool;
let pool = VCLPool::new(10);
Source

pub async fn bind(&mut self, addr: &str) -> Result<ConnectionId, VCLError>

Bind a new connection to a local UDP address and add it to the pool.

Returns the ConnectionId assigned to this connection.

§Errors
Source

pub async fn connect( &mut self, id: ConnectionId, addr: &str, ) -> Result<(), VCLError>

Connect a pooled connection to a remote peer (client side handshake).

§Errors
Source

pub async fn accept_handshake( &mut self, id: ConnectionId, ) -> Result<(), VCLError>

Accept an incoming handshake on a pooled connection (server side).

§Errors
Source

pub async fn send( &mut self, id: ConnectionId, data: &[u8], ) -> Result<(), VCLError>

Send data on a pooled connection.

§Errors
Source

pub async fn recv(&mut self, id: ConnectionId) -> Result<VCLPacket, VCLError>

Receive the next data packet on a pooled connection.

§Errors
Source

pub async fn ping(&mut self, id: ConnectionId) -> Result<(), VCLError>

Send a ping on a pooled connection.

§Errors
Source

pub async fn rotate_keys(&mut self, id: ConnectionId) -> Result<(), VCLError>

Rotate keys on a pooled connection.

§Errors
Source

pub fn close(&mut self, id: ConnectionId) -> Result<(), VCLError>

Close a specific connection and remove it from the pool.

§Errors
Source

pub fn close_all(&mut self)

Close all connections and clear the pool.

Source

pub fn len(&self) -> usize

Returns the number of active connections in the pool.

Source

pub fn is_empty(&self) -> bool

Returns true if the pool has no active connections.

Source

pub fn is_full(&self) -> bool

Returns true if the pool has reached its maximum capacity.

Source

pub fn connection_ids(&self) -> Vec<ConnectionId>

Returns a list of all active ConnectionIds in the pool.

Source

pub fn contains(&self, id: ConnectionId) -> bool

Returns true if a connection with the given ID exists in the pool.

Source

pub fn get(&self, id: ConnectionId) -> Result<&VCLConnection, VCLError>

Get a reference to a connection by ID.

§Errors

Returns VCLError::InvalidPacket if the ID is not found.

Trait Implementations§

Source§

impl Drop for VCLPool

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more