Depend on negentropy

This commit is contained in:
Mike Dilger 2025-01-21 09:04:19 +13:00
parent 6f7fde4bbc
commit ac87fc9d29
No known key found for this signature in database
GPG Key ID: 47581A78D4329BA4
3 changed files with 23 additions and 0 deletions

7
Cargo.lock generated
View File

@ -279,6 +279,7 @@ dependencies = [
"log",
"mime-sniffer",
"mime2ext",
"negentropy",
"parking_lot",
"pocket-db",
"pocket-types",
@ -1147,6 +1148,12 @@ dependencies = [
"memmap2",
]
[[package]]
name = "negentropy"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a88da9dd148bbcdce323dd6ac47d369b4769d4a3b78c6c52389b9269f77932"
[[package]]
name = "nom"
version = "7.1.3"

View File

@ -23,6 +23,7 @@ lazy_static = "1.5"
log = "0.4"
mime-sniffer = "0.1"
mime2ext = "0.1"
negentropy = "0.4"
pocket-types = { git = "https://github.com/mikedilger/pocket", branch = "master" }
pocket-db = { git = "https://github.com/mikedilger/pocket", branch = "master" }
parking_lot = "0.12"

View File

@ -104,6 +104,9 @@ pub enum ChorusError {
// Missing Table
MissingTable(&'static str),
// Negentropy error
Negentropy(negentropy::Error),
// Non-ASCII HTTP header value
NonAsciiHttpHeaderValue(http::header::ToStrError),
@ -209,6 +212,7 @@ impl std::fmt::Display for ChorusError {
ChorusError::Io(e) => write!(f, "{e}"),
ChorusError::ManagementAuthFailure(s) => write!(f, "Authorization failure: {s}"),
ChorusError::MissingTable(t) => write!(f, "Missing table: {t}"),
ChorusError::Negentropy(e) => write!(f, "Negentropy: {e}"),
ChorusError::NonAsciiHttpHeaderValue(e) => {
write!(f, "Non ASCII HTTP header value: {e}")
}
@ -308,6 +312,7 @@ impl ChorusError {
ChorusError::Io(_) => 0.0,
ChorusError::ManagementAuthFailure(_) => 0.0,
ChorusError::MissingTable(_) => 0.0,
ChorusError::Negentropy(_) => 0.1,
ChorusError::NonAsciiHttpHeaderValue(_) => 0.2,
ChorusError::NoPrivateKey => 0.0,
ChorusError::NotImplemented => 0.0,
@ -583,6 +588,16 @@ impl From<base64::DecodeError> for Error {
}
}
impl From<negentropy::Error> for Error {
#[track_caller]
fn from(e: negentropy::Error) -> Error {
Error {
inner: ChorusError::Negentropy(e),
location: std::panic::Location::caller(),
}
}
}
impl From<Infallible> for Error {
fn from(_: Infallible) -> Self {
panic!("INFALLIBLE")