pub struct AsyncMux(/* private fields */);Expand description
Asynchronous version of Mux.
Implementations§
Source§impl AsyncMux
impl AsyncMux
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 AsyncMux.
This will create a temporary directory for all the sockets managed by this AsyncMux;
dropping the AsyncMux 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 AsyncMux, with temporary directory under the specified path.
This will create a temporary directory for all the sockets managed by this AsyncMux;
dropping the AsyncMux 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 async fn read<'mux>(&'mux mut self) -> Result<TaggedData<'mux>>
pub async fn read<'mux>(&'mux mut self) -> Result<TaggedData<'mux>>
Return the next chunk of data, together with its tag.
This reuses a buffer managed by the AsyncMux.
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. Once the source of the data
exits, call read_nonblock instead, until it returns None.
Sourcepub fn read_nonblock<'mux>(&'mux mut self) -> Result<Option<TaggedData<'mux>>>
pub fn read_nonblock<'mux>(&'mux mut self) -> Result<Option<TaggedData<'mux>>>
Return the next chunk of data, together with its tag, if available immediately, or None if the read would block.
This reuses a buffer managed by the AsyncMux.
Use this if you know no more data will get sent and you want to drain the remaining data.