pub enum Error {
BadMagic {
expected: HexBytes,
got: HexBytes,
},
Truncated {
need: usize,
at: usize,
have: usize,
},
Malformed {
at: usize,
reason: String,
},
ImplausibleLength {
what: &'static str,
length: u64,
limit: u64,
},
Binrw(Error),
}Expand description
What went wrong decoding or encoding a Pro DJ Link message.
Variants§
BadMagic
The datagram does not carry the Pro DJ Link magic, or a message does not carry the magic its format requires.
Truncated
The buffer ends before a field this format requires.
For a stream protocol this is the expected outcome of trying to decode
too early, so callers distinguish it from Error::Malformed to decide
between “wait for more bytes” and “drop the connection”.
Fields
Malformed
A field holds a value the format does not allow. Unlike
Error::Truncated, more bytes will not help.
ImplausibleLength
A length prefix claims more than any real message carries. Rejected before allocating, so a corrupt or hostile word costs a parse failure rather than four gigabytes.
Fields
Binrw(Error)
A binrw-derived codec failed.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_truncated(&self) -> bool
pub fn is_truncated(&self) -> bool
True when more bytes could make this parse succeed.
The distinction that matters on a TCP stream: a dbserver message is framed by nothing but its own contents, so running off the end of the buffer means “wait”, and anything else means “this connection is not speaking the protocol”.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()