pub trait Socket: GetSocket + Sized {
// Provided method
fn with<T>(self, setup: T) -> Result<Self>
where T: FnOnce(&mut Self) -> Result<&mut Self> { ... }
}Expand description
Type which is an NngSocket.
Provided Methods§
Sourcefn with<T>(self, setup: T) -> Result<Self>
fn with<T>(self, setup: T) -> Result<Self>
Helper to chain constructors with methods that return &Self.
§Examples
use runng::{Listen, protocol::Pair0, Socket};
fn main() -> runng::Result<()> {
let mut socket0 = Pair0::open()?;
socket0.listen("inproc://socket0")?;
// VS
let socket1 = Pair0::open()?.with(|sock| sock.listen("inproc://socket1"))?;
Ok(())
}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.