1use std::io;
2use std::sync::PoisonError;
3
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum Error {
9 #[error("FrDT magic is missing")]
10 BadMagic,
11 #[error("reserved header bytes are not zero")]
12 BadReserved,
13 #[error("unsupported compression method {0:#x}")]
14 UnsupportedCompression(u64),
15 #[error("truncated input")]
16 Truncated,
17 #[error("unsupported BSON type {0:#x}")]
18 UnsupportedType(u8),
19 #[error("invalid BSON: {0}")]
20 Invalid(String),
21 #[error("slot not found")]
22 NotFound,
23 #[error("field not found: {0}")]
24 FieldNotFound(String),
25 #[error("BSON document exceeds the 32-bit length prefix")]
26 TooLarge,
27 #[error("brotli quality must be 4, 5, or 6")]
28 BadQuality,
29 #[error("document lock poisoned")]
30 Poisoned,
31 #[error("io: {0}")]
32 Io(#[from] io::Error),
33}
34
35pub type Result<T> = std::result::Result<T, Error>;
36
37impl<T> From<PoisonError<T>> for Error {
38 fn from(_: PoisonError<T>) -> Self {
39 Error::Poisoned
40 }
41}