pub struct FabricListener { /* private fields */ }Expand description
A TCP listener bound to a leased fabric network interface.
Accepts connections on a specific port, with the bandwidth guarantee
from the underlying NetLease. On native targets, delegates to
std::net::TcpListener.
§Example
use grafos_net::FabricListener;
use grafos_std::net::NetBuilder;
let lease = NetBuilder::new().acquire()?;
let listener = FabricListener::bind(lease, 0)?;
let addr = listener.local_addr()?;
println!("listening on {}", addr);Implementations§
Source§impl FabricListener
impl FabricListener
Sourcepub fn bind(lease: NetLease, port: u16) -> Result<Self>
pub fn bind(lease: NetLease, port: u16) -> Result<Self>
Bind a listener to the given port on the leased interface.
On native targets, binds to 0.0.0.0:port.
§Errors
Returns an I/O error if the bind fails.
Sourcepub fn accept(&self) -> Result<(TcpStream, SocketAddr)>
pub fn accept(&self) -> Result<(TcpStream, SocketAddr)>
Accept a new incoming connection.
Returns the connected stream and the peer’s address.
§Errors
Returns an I/O error if the accept fails.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address this listener is bound to.
§Errors
Returns an I/O error if the address cannot be retrieved.
Auto Trait Implementations§
impl Freeze for FabricListener
impl !RefUnwindSafe for FabricListener
impl !Send for FabricListener
impl !Sync for FabricListener
impl Unpin for FabricListener
impl !UnwindSafe for FabricListener
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