nardol 0.0.3

Simple framework that provides structure to data sent and received from network.
Documentation
/// Enum containing all error kinds used in [nardol](crate).
#[derive(Debug)]
pub enum ErrorKind {
    /// Used if [Packet](crate::packet::Packet) size is bigger than
    /// [MAX_PACKET_SIZE](crate::packet::MAX_PACKET_SIZE).
    TooBigPacket,

    /// Used if packet kind was not expected or a function or a method was used on wrong
    /// [PacketKind](crate::packet::PacketKind) variant.
    InvalidPacketKind,
    /// Used if fails to recognize [PacketKind](crate::packet::PacketKind).
    UnknownPacketKind,

    /// Used if serializing struct with [serde] fails.
    SerializingFailed,
    /// Used if deserializing struct with [serde] fails.
    DeserializingFailed,

    /// Used if buffer size is not valid for the operation,
    ///  usually used in implementations of [`TryFrom<Bytes>`](TryFrom).
    InvalidBufferSize,

    /// Used if an error occurs during writing to [TcpStream](std::net::TcpStream).
    WritingToStreamFailed,
    /// Used if an error occurs during reading from [TcpStream](std::net::TcpStream).
    ReadingFromStreamFailed,

    /// Used if and error occurs during sending data to the address using an
    /// [UdpSocket](std::net::UdpSocket)
    SendingToAddressFailed,
    /// Used if and error occurs during receiving data from the address using an
    /// [UdpSocket](std::net::UdpSocket)
    ReceivingFromAddressFailed,

    /// Used if an error occurs while trying to create a directory.
    CreatingDirFailed,
    /// Used if an error occurs while trying to create a file.
    CreatingFileFailed,
    /// Used if an error occurs while trying to open a file.
    OpeningFileFailed,
    /// Used if an error occurs while trying to write to a file.
    WritingToFileFailed,
    /// Used if an error occurs while trying to read from a file.
    ReadingFromFileFailed,

    /// Used if anything fails to parse.
    ParsingFailed,

    /// Wrapper around every error not originating from this library,
    /// used if there is a need to use produced error directly.
    OtherSource(Box<dyn std::error::Error>),
}

impl std::fmt::Display for ErrorKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "ErrorKind")
    }
}