stream_multiplexer/
error.rs

1use crate::*;
2
3// FIXME: Remove dependency on thiserror when Futures changes to pin-project-lite
4// https://github.com/rust-lang/futures-rs/issues/2170
5
6/// Errors returned by `Multiplexer`.
7#[derive(thiserror::Error, Debug)]
8pub enum MultiplexerError<SE: std::fmt::Debug> {
9    /// `StreamId` could not be added to `ChannelId`
10    #[error("Could not add stream {0} to channel {1}.")]
11    ChannelAdd(StreamId, ChannelId),
12
13    /// The internal storage for `streams` in a channel is full.
14    #[error("Could not add stream to full channel {0}.")]
15    ChannelFull(ChannelId),
16
17    /// `ChannelId` already exists and cannot be added again.
18    #[error("Channel {0} already exists")]
19    DuplicateChannel(ChannelId),
20
21    /// `StreamId` is not recognized.
22    #[error("Stream {0} does not exist.")]
23    UnknownStream(StreamId),
24
25    /// `ChannelId` is not recognized.
26    #[error("Channel {0} is unknown.")]
27    UnknownChannel(ChannelId),
28
29    /// `StreamId` could not be sent to.
30    #[error("Could not send item to sink {0} due to {1:?}")]
31    SendError(StreamId, SE),
32}