redis_subscribe/
error.rs

1use std::{io, str::Utf8Error};
2
3use thiserror::Error;
4
5/// All possible errors returned by this library.
6#[derive(Error, Debug)]
7pub enum Error {
8    /// An IO error happened on the underlying TCP stream.
9    #[error(transparent)]
10    IoError(#[from] io::Error),
11    /// An error happened while decoding the data from Redis as UTF-8.
12    #[error(transparent)]
13    Utf8Error(#[from] Utf8Error),
14    /// The parser implementation returned an error.
15    #[error("Failed to parse the incoming Redis message.")]
16    ParserError(#[from] crate::message::ParserError),
17    /// You attempted to unsubscribe from a channel that you were not subscribed to.
18    #[error("Not subscribed to the supplied channel.")]
19    NotSubscribed,
20    /// Zero bytes were read from the TCP socket: this is an IO error and is usually fatal.
21    #[error("No bytes are read from the socket, socket is closed.")]
22    ZeroBytesRead,
23}
24
25/// An wrapper around the standard [Result] type with [Error] aliased to this crate's error type.
26///
27/// [Result]: std::result::Result
28/// [Error]: crate::error::Error
29pub type Result<T> = std::result::Result<T, Error>;