pub struct Mux { /* private fields */ }
Expand description
A Mux
provides a single receive end and multiple send ends. Data sent to any of the send ends
comes out the receive end, in order, tagged by the sender.
Mux
implements AsFd
solely to support polling the underlying file descriptor for data to
read. Always use Mux
to perform the actual read.
Implementations§
Source§impl Mux
impl Mux
Sourcepub fn new_abstract() -> Result<Self>
pub fn new_abstract() -> Result<Self>
Create a new Mux
, using Linux abstract sockets.
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new Mux
.
This will create a temporary directory for all the sockets managed by this Mux
; dropping
the Mux
removes the temporary directory.
Sourcepub fn new_in<P: AsRef<Path>>(dir: P) -> Result<Self>
pub fn new_in<P: AsRef<Path>>(dir: P) -> Result<Self>
Create a new Mux
, with temporary directory under the specified path.
This will create a temporary directory for all the sockets managed by this Mux
; dropping
the Mux
removes the temporary directory.
Sourcepub fn make_sender(&self) -> Result<(Tag, MuxSender)>
pub fn make_sender(&self) -> Result<(Tag, MuxSender)>
Create a new MuxSender
and associated unique Tag
. Data sent via the returned
MuxSender
will arrive with the corresponding Tag
.
Sourcepub fn read(&mut self) -> Result<TaggedData<'_>>
pub fn read(&mut self) -> Result<TaggedData<'_>>
Return the next chunk of data, together with its tag.
This reuses a buffer managed by the Mux
.
Note that this provides no “EOF” indication; if no further data arrives, it will block forever. Avoid calling it after the source of the data exits.