Struct ya_relay_stack::Network

source ·
pub struct Network {
    pub name: Rc<String>,
    pub config: Rc<StackConfig>,
    pub stack: Stack<'static>,
    pub bindings: Rc<RefCell<HashSet<SocketHandle>>>,
    pub connections: Rc<RefCell<HashMap<ConnectionMeta, Connection>>>,
    pub handles: Rc<RefCell<HashMap<SocketHandle, ConnectionMeta>>>,
    /* private fields */
}

Fields§

§name: Rc<String>§config: Rc<StackConfig>§stack: Stack<'static>§bindings: Rc<RefCell<HashSet<SocketHandle>>>

Set of listening sockets. Socket is removed from this set, when connection is created. Network stack will create new binding using new handle in place of previous.

§connections: Rc<RefCell<HashMap<ConnectionMeta, Connection>>>§handles: Rc<RefCell<HashMap<SocketHandle, ConnectionMeta>>>

Implementations§

source§

impl Network

source

pub fn new( name: impl ToString, config: Rc<StackConfig>, stack: Stack<'static> ) -> Self

Creates a new Network instance

source

pub fn get_bound( &self, protocol: Protocol, local_endpoint: impl Into<SocketEndpoint> ) -> Option<SocketHandle>

Returns a socket listening on an endpoint and ready for incoming connections. Sockets already connected won’t be returned.

source

pub fn bind( &self, protocol: Protocol, endpoint: impl Into<SocketEndpoint> ) -> Result<SocketHandle>

Listen on a local endpoint

source

pub fn unbind( &self, protocol: Protocol, endpoint: impl Into<SocketEndpoint> ) -> Result<()>

Stop listening on a local endpoint

source

pub fn connect( &self, remote: impl Into<IpEndpoint>, timeout: impl Into<Duration> ) -> LocalBoxFuture<'_, Result<Connection>>

Initiate a TCP connection

source

pub fn disconnect_all( &self, remote_ip: Box<[u8]>, timeout: impl Into<Duration> ) -> LocalBoxFuture<'_, ()>

Close all TCP connections with a remote IP address

source

pub fn bindings(&self) -> Ref<'_, HashSet<SocketHandle>>

source

pub fn handles(&self) -> Ref<'_, HashMap<SocketHandle, ConnectionMeta>>

source

pub fn connections(&self) -> Ref<'_, HashMap<ConnectionMeta, Connection>>

source

pub fn sockets(&self) -> Vec<(SocketDesc, SocketState<ChannelMetrics>)>

source

pub fn sockets_meta( &self ) -> Vec<(SocketHandle, SocketDesc, SocketState<ChannelMetrics>)>

source

pub fn metrics(&self) -> ChannelMetrics

source

pub fn send<'a>( &self, data: impl Into<Payload>, connection: Connection ) -> impl Future<Output = Result<()>> + 'a

Inject send data into the stack

source

pub fn receive(&self, data: impl Into<Payload>)

Inject received data into the stack

source

pub fn spawn_local(&self)

source

pub fn poll(&self)

Polls the inner network stack

source

pub fn ingress_receiver(&self) -> Option<IngressReceiver>

Take the ingress traffic receive channel

source

pub fn egress_receiver(&self) -> Option<EgressReceiver>

Take the egress traffic receive channel

Trait Implementations§

source§

impl Clone for Network

source§

fn clone(&self) -> Network

Returns a copy 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§

§

impl !RefUnwindSafe for Network

§

impl !Send for Network

§

impl !Sync for Network

§

impl Unpin for Network

§

impl !UnwindSafe for Network

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V