//! Soulseek protocol messages and binary codecs. //! //! Wire format: every message is `[u32 length][code][payload]`, little-endian //! throughout. Server and peer messages use a `u32` code; connection //! initialization messages (PeerInit / PierceFirewall) use a single-byte code. //! Strings are `[u32 len][bytes]`, UTF-8 with Latin-1 fallback on decode. //! Search responses and browse payloads are zlib-compressed after the code. //! //! Reference: Soulseek.NET `src/Messaging/**` and the Nicotine+ protocol docs. pub mod dist; pub mod peer; pub mod server; pub mod types; pub mod wire; #[derive(Debug, thiserror::Error)] pub enum ProtoError { #[error("message payload ended unexpectedly")] UnexpectedEof, #[error("zlib decompression failed: {0}")] Zlib(#[from] std::io::Error), #[error("message too large: {0} bytes")] TooLarge(usize), } pub type Result = std::result::Result; /// Sanity cap on a single message frame (search responses from big shares /// run a few hundred KB; browse responses can reach tens of MB). pub const MAX_MESSAGE_SIZE: usize = 64 * 1024 * 1024;