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
impl Network
Sourcepub fn new(
name: impl ToString,
config: Rc<StackConfig>,
stack: Stack<'static>,
) -> Self
pub fn new( name: impl ToString, config: Rc<StackConfig>, stack: Stack<'static>, ) -> Self
Creates a new Network instance
Sourcepub fn get_bound(
&self,
protocol: Protocol,
local_endpoint: impl Into<SocketEndpoint>,
) -> Option<SocketHandle>
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.
Sourcepub fn bind(
&self,
protocol: Protocol,
endpoint: impl Into<SocketEndpoint>,
) -> Result<SocketHandle>
pub fn bind( &self, protocol: Protocol, endpoint: impl Into<SocketEndpoint>, ) -> Result<SocketHandle>
Listen on a local endpoint
Sourcepub fn unbind(
&self,
protocol: Protocol,
endpoint: impl Into<SocketEndpoint>,
) -> Result<()>
pub fn unbind( &self, protocol: Protocol, endpoint: impl Into<SocketEndpoint>, ) -> Result<()>
Stop listening on a local endpoint
Sourcepub fn connect(
&self,
remote: impl Into<IpEndpoint>,
timeout: impl Into<Duration>,
) -> LocalBoxFuture<'_, Result<Connection>>
pub fn connect( &self, remote: impl Into<IpEndpoint>, timeout: impl Into<Duration>, ) -> LocalBoxFuture<'_, Result<Connection>>
Initiate a TCP connection
Sourcepub fn disconnect_all(
&self,
remote_ip: Box<[u8]>,
timeout: impl Into<Duration>,
) -> LocalBoxFuture<'_, ()>
pub fn disconnect_all( &self, remote_ip: Box<[u8]>, timeout: impl Into<Duration>, ) -> LocalBoxFuture<'_, ()>
Close all TCP connections with a remote IP address
pub fn bindings(&self) -> Ref<'_, HashSet<SocketHandle>>
pub fn handles(&self) -> Ref<'_, HashMap<SocketHandle, ConnectionMeta>>
pub fn connections(&self) -> Ref<'_, HashMap<ConnectionMeta, Connection>>
pub fn sockets(&self) -> Vec<(SocketDesc, SocketState<ChannelMetrics>)>
pub fn sockets_meta( &self, ) -> Vec<(SocketHandle, SocketDesc, SocketState<ChannelMetrics>)>
pub fn metrics(&self) -> ChannelMetrics
Sourcepub fn send<'a>(
&self,
data: impl Into<Payload>,
connection: Connection,
) -> impl Future<Output = Result<()>> + 'a
pub fn send<'a>( &self, data: impl Into<Payload>, connection: Connection, ) -> impl Future<Output = Result<()>> + 'a
Inject send data into the stack
pub fn spawn_local(&self)
Sourcepub fn ingress_receiver(&self) -> Option<IngressReceiver>
pub fn ingress_receiver(&self) -> Option<IngressReceiver>
Take the ingress traffic receive channel
Sourcepub fn egress_receiver(&self) -> Option<EgressReceiver>
pub fn egress_receiver(&self) -> Option<EgressReceiver>
Take the egress traffic receive channel
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more