TcpListenerExt

Trait TcpListenerExt 

Source
pub trait TcpListenerExt {
    // Required method
    fn cap_bind<A>(agent: &mut CapNetAgent, addrs: A) -> Result<TcpListener>
       where A: ToSocketAddrs;
}
Expand description

Adds extra features to std::net::TcpListener that require Casper.

Required Methods§

Source

fn cap_bind<A>(agent: &mut CapNetAgent, addrs: A) -> Result<TcpListener>
where A: ToSocketAddrs,

Create a new TcpListener bound to the specified address.

§Examples
use std::{io, str::FromStr, net::TcpListener };

use capsicum::casper::Casper;
use capsicum_net::{CasperExt, std::TcpListenerExt};

// Safe because we are single-threaded
let mut casper = unsafe { Casper::new().unwrap() };
let mut cap_net = casper.net().unwrap();

let socket = TcpListener::cap_bind(&mut cap_net, "127.0.0.1:8084")
    .unwrap();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TcpListenerExt for TcpListener

Source§

fn cap_bind<A>(agent: &mut CapNetAgent, addrs: A) -> Result<TcpListener>
where A: ToSocketAddrs,

Implementors§