Trait portus::ipc::Ipc

source ·
pub trait Ipc: 'static + Send {
    type Addr: Clone + Default + Eq + Hash + Debug;

    // Required methods
    fn name() -> String;
    fn send(&self, msg: &[u8], to: &Self::Addr) -> Result<()>;
    fn recv(&self, msg: &mut [u8]) -> Result<(usize, Self::Addr)>;
    fn close(&mut self) -> Result<()>;
}
Expand description

IPC mechanisms must implement this trait.

This API enables both connection-oriented (send/recv) and connectionless (sendto/recvfrom) sockets, but currently only unix sockets support connectionless sockets. When using unix sockets, you must provide a valid Addr to send() and you will also receive a valid Addr as a return value from recv. When using connection-oriented ipc mechanisms, these values are ignored and should just be the nil value ().

Required Associated Types§

Required Methods§

source

fn name() -> String

Returns the name of this IPC mechanism (e.g. “netlink” for Linux netlink sockets)

source

fn send(&self, msg: &[u8], to: &Self::Addr) -> Result<()>

Blocking send

source

fn recv(&self, msg: &mut [u8]) -> Result<(usize, Self::Addr)>

Blocking listen.

Returns how many bytes were read, and (if using unix sockets) the address of the sender.

Important: should not allocate!

source

fn close(&mut self) -> Result<()>

Close the underlying sockets

Implementors§

source§

impl Ipc for portus::ipc::chan::Socket<Blocking>

§

type Addr = ()

source§

impl Ipc for portus::ipc::chan::Socket<Nonblocking>

§

type Addr = ()

source§

impl<T: 'static + Sync + Send> Ipc for portus::ipc::unix::Socket<T>