pub trait UdpSocketExt {
// Required methods
fn cap_bind<A>(agent: &mut CapNetAgent, addr: A) -> Result<UdpSocket>
where A: ToSocketAddrs;
fn cap_connect<A>(&self, agent: &mut CapNetAgent, addrs: A) -> Result<()>
where A: ToSocketAddrs;
}Expand description
Adds extra features to std::net::UdpSocket that require Casper.
Required Methods§
Sourcefn cap_bind<A>(agent: &mut CapNetAgent, addr: A) -> Result<UdpSocket>where
A: ToSocketAddrs,
fn cap_bind<A>(agent: &mut CapNetAgent, addr: A) -> Result<UdpSocket>where
A: ToSocketAddrs,
Bind a std::net::UdpSocket to a port.
§Examples
use std::{io, str::FromStr, net::UdpSocket };
use capsicum::casper::Casper;
use capsicum_net::{CasperExt, std::UdpSocketExt};
// Safe because we are single-threaded
let mut casper = unsafe { Casper::new().unwrap() };
let mut cap_net = casper.net().unwrap();
let socket = UdpSocket::cap_bind(&mut cap_net, "127.0.0.1:8088")
.unwrap();Sourcefn cap_connect<A>(&self, agent: &mut CapNetAgent, addrs: A) -> Result<()>where
A: ToSocketAddrs,
fn cap_connect<A>(&self, agent: &mut CapNetAgent, addrs: A) -> Result<()>where
A: ToSocketAddrs,
Connects this UDP socket to a remote address, using a cap_net service.
§Examples
use std::{io, str::FromStr, net::UdpSocket };
use capsicum::casper::Casper;
use capsicum_net::{CasperExt, std::UdpSocketExt};
// Safe because we are single-threaded
let mut casper = unsafe { Casper::new().unwrap() };
let mut cap_net = casper.net().unwrap();
let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
socket.cap_connect(&mut cap_net, "8.8.8.8:53").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.