packet_parser 1.4.0

A powerful and modular Rust crate for network packet parsing.
Documentation
// Copyright (c) 2026 Cyprien Avico avicocyprien@yahoo.com
//
// Licensed under the MIT License <LICENSE-MIT or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.

use thiserror::Error;

use crate::errors::transport::{tcp::TcpError, udp::UdpError};

pub mod tcp;
pub mod udp;

/// Errors that can occur when parsing transport layer packets
#[derive(Error, Debug)]
pub enum TransportError {
    #[error("Packet is too short to be a valid transport packet")]
    PacketTooShort,

    #[error("Invalid TCP packet: {0}")]
    InvalidTcpPacket(String),

    #[error("UDP error: {0}")]
    UdpError(#[from] UdpError),

    #[error("TCP error: {0}")]
    TcpError(#[from] TcpError),

    #[error("Unsupported transport protocol")]
    UnsupportedProtocol,
}