socketio-next 0.2.1

Socket.IO v4 / Engine.IO v4 client with socket.io-client 4.8 parity: async (tokio) and blocking, rustls or native-tls
Documentation
use std::str::Utf8Error;
use std::sync::Arc;

/// A packet that does not follow the Engine.IO v4 / Socket.IO v5 wire format.
#[derive(Debug, Clone, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
    /// The first character is not a known packet type.
    #[error("unknown packet type {0:?}")]
    InvalidPacketType(char),
    /// The packet ends before a required part (type, attachment count, namespace).
    #[error("incomplete packet")]
    IncompletePacket,
    /// The packet breaks a protocol rule; the text says which.
    #[error("invalid packet: {0}")]
    InvalidPacket(&'static str),
    /// A text packet is not valid UTF-8.
    #[error("packet is not valid UTF-8: {0}")]
    InvalidUtf8(#[from] Utf8Error),
    /// A `b`-prefixed (base64) engine.io packet does not decode.
    #[error("invalid base64 in a binary packet: {0}")]
    InvalidBase64(#[from] base64::DecodeError),
    /// The JSON payload does not parse.
    #[error("invalid JSON payload: {0}")]
    InvalidJson(#[source] Arc<serde_json::Error>),
}

impl From<serde_json::Error> for Error {
    fn from(err: serde_json::Error) -> Self {
        Error::InvalidJson(Arc::new(err))
    }
}

/// Result alias of this crate.
pub type Result<T> = std::result::Result<T, Error>;