Files
smartdb/rust/crates/rustdb-wire/src/error.rs

28 lines
806 B
Rust

/// Errors from wire protocol parsing/encoding.
#[derive(Debug, thiserror::Error)]
pub enum WireError {
#[error("Incomplete message: need {needed} bytes, have {have}")]
Incomplete { needed: usize, have: usize },
#[error("Unsupported opCode: {0}")]
UnsupportedOpCode(i32),
#[error("Missing command body section in OP_MSG")]
MissingBody,
#[error("Unknown section type: {0}")]
UnknownSectionType(u8),
#[error("BSON deserialization error: {0}")]
BsonError(#[from] bson::de::Error),
#[error("BSON serialization error: {0}")]
BsonSerError(#[from] bson::ser::Error),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("Checksum mismatch: expected {expected}, got {actual}")]
ChecksumMismatch { expected: u32, actual: u32 },
}