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

§

impl Freeze for Network

§

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

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

Source§

fn vzip(self) -> V