use super::channels::ChannelId;
#[derive(thiserror::Error, Debug)]
pub enum AsyncChannelError {
#[error("The data could not be sent on the channel because the channel is currently full and sending would require blocking")]
FullQueue,
#[error(
"The receiving half of the internal channel was explicitly closed or has been dropped"
)]
InternalChannelClosed,
}
#[derive(thiserror::Error, Debug)]
pub enum ChannelCloseError {
#[error("Channel is closed already")]
ChannelAlreadyClosed,
#[error("Channel with id `{0}` is invalid")]
InvalidChannelId(ChannelId),
}
#[derive(thiserror::Error, Debug)]
pub enum ChannelCreationError {
#[error("The maximum number of simultaneously opened channels has been reached")]
MaxChannelsCountReached,
#[error("Quinnet async channel error")]
AsyncChannelError(#[from] AsyncChannelError),
}
#[derive(thiserror::Error, Debug)]
pub enum ChannelConfigError {
#[error("The maximum number of configured channels has been reached")]
MaxChannelsCountReached,
}
#[derive(thiserror::Error, Debug)]
pub enum ConnectionSendError {
#[error("Channel with id `{0}` is invalid")]
InvalidChannelId(ChannelId),
#[error("Channel is closed")]
ChannelClosed,
#[error("Quinnet async channel error")]
ChannelSendError(#[from] AsyncChannelError),
}
#[derive(thiserror::Error, Debug)]
#[error("Connection is already closed")]
pub struct ConnectionAlreadyClosed;
#[cfg(feature = "recv_channels")]
#[derive(thiserror::Error, Debug, Clone)]
#[error("Error while receiving payload on a recv channel")]
pub enum RecvChannelError {
#[error("Channel queue with id {0} is full, a payload has been dropped")]
RecvChannelFull(ChannelId),
#[error(
"The maximum number of opened receive channels has been reached, triggered by channel id {0}. A payload has been dropped"
)]
MaxRecvChannelCountReached(ChannelId),
}
#[cfg(feature = "recv_channels")]
#[derive(bevy::ecs::message::Message, Debug, Clone)]
pub struct RecvChannelErrorEvent<T> {
pub id: T,
pub error: RecvChannelError,
}