mod base;
mod builder;
mod error;
pub mod io;
pub use base::{CompressionState, EncryptionState, Packet, PacketCodec, PacketValidation};
pub use builder::PacketBuilder;
pub use error::{PacketError, PacketResult};
pub use io::{PacketReader, PacketWriter};
pub const MAX_PACKET_LENGTH: usize = 2097151; pub const MAX_PACKET_DATA_LENGTH: usize = 0x200000; pub const MAX_UNCOMPRESSED_LENGTH: usize = 8388608;
#[cfg(test)]
mod tests {
use super::*;
use bytes::BytesMut;
#[test]
fn test_packet_creation_workflow() {
let packet = PacketBuilder::new()
.id(0x00)
.data(BytesMut::from(&b"test"[..]))
.with_compression(256)
.build()
.unwrap();
assert_eq!(packet.id, 0x00);
assert_eq!(&packet.data[..], b"test");
assert!(matches!(
packet.compression,
CompressionState::Enabled { threshold: 256 }
));
}
}