Remove sled and all related crates from dependencies.

This commit is contained in:
projectmoon 2021-05-21 14:21:22 +00:00
parent 059538b95d
commit 402f236ba7
4 changed files with 2 additions and 94 deletions

41
Cargo.lock generated
View File

@ -180,15 +180,6 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bitflags"
version = "1.2.1"
@ -1203,12 +1194,6 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "memmem"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15"
[[package]]
name = "memoffset"
version = "0.6.3"
@ -2513,8 +2498,6 @@ version = "0.10.0"
dependencies = [
"async-trait",
"barrel",
"bincode",
"byteorder",
"combine",
"dirs",
"futures",
@ -2523,13 +2506,11 @@ dependencies = [
"itertools",
"log",
"matrix-sdk",
"memmem",
"nom 5.1.2",
"phf",
"rand 0.8.3",
"refinery",
"serde",
"sled",
"sqlx",
"tempfile",
"thiserror",
@ -2537,7 +2518,6 @@ dependencies = [
"toml",
"tracing-subscriber",
"url",
"zerocopy",
]
[[package]]
@ -3093,27 +3073,6 @@ dependencies = [
"time 0.1.43",
]
[[package]]
name = "zerocopy"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e59ec1d2457bd6c0dd89b50e7d9d6b0b647809bf3f0a59ac85557046950b7b2"
dependencies = [
"byteorder",
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0af017aca1fa6181f5dd7a802456fe6f7666ecdcc18d0910431f0fc89d474e51"
dependencies = [
"proc-macro2",
"syn",
"synstructure",
]
[[package]]
name = "zeroize"
version = "1.3.0"

View File

@ -27,12 +27,7 @@ url = "2.1"
dirs = "3.0"
indoc = "1.0"
combine = "4.5"
sled = "0.34"
zerocopy = "0.5"
byteorder = "1.3"
futures = "0.3"
memmem = "0.1"
bincode = "1.3"
html2text = "0.2"
phf = { version = "0.8", features = ["macros"] }
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", branch = "master" }

View File

@ -1,6 +1,4 @@
use std::num::TryFromIntError;
use sled::transaction::{TransactionError, UnabortableTransactionError};
use thiserror::Error;
#[derive(Error, Debug)]
@ -23,50 +21,12 @@ pub enum DataError {
#[error("expected string, but utf8 schema was violated: {0}")]
Utf8SchemaViolation(#[from] std::string::FromUtf8Error),
#[error("internal database error: {0}")]
InternalError(#[from] sled::Error),
#[error("transaction error: {0}")]
TransactionError(#[from] sled::transaction::TransactionError),
#[error("unabortable transaction error: {0}")]
UnabortableTransactionError(#[from] UnabortableTransactionError),
#[error("data migration error: {0}")]
MigrationError(#[from] crate::db::sqlite::migrator::MigrationError),
#[error("deserialization error: {0}")]
DeserializationError(#[from] bincode::Error),
#[error("sqlx error: {0}")]
#[error("internal database error: {0}")]
SqlxError(#[from] sqlx::Error),
#[error("numeric conversion error")]
NumericConversionError(#[from] TryFromIntError),
}
/// This From implementation is necessary to deal with the recursive
/// error type in the error enum. We defined a transaction error, but
/// the only place we use it is when converting from
/// sled::transaction::TransactionError<DataError>. This converter
/// extracts the inner data error from transaction aborted errors, and
/// forwards anything else onward as-is, but wrapped in DataError.
impl From<TransactionError<DataError>> for DataError {
fn from(error: TransactionError<DataError>) -> Self {
match error {
TransactionError::Abort(data_err) => data_err,
TransactionError::Storage(storage_err) => {
DataError::TransactionError(TransactionError::Storage(storage_err))
}
}
}
}
/// Automatically aborts transactions that hit a DataError by using
/// the try (question mark) operator when this trait implementation is
/// in scope.
impl From<DataError> for sled::transaction::ConflictableTransactionError<DataError> {
fn from(error: DataError) -> Self {
sled::transaction::ConflictableTransactionError::Abort(error)
}
}

View File

@ -1,6 +1,6 @@
use crate::commands::CommandError;
use crate::config::ConfigError;
use crate::db::errors::DataError;
use crate::{commands::CommandError, db::sqlite::migrator};
use thiserror::Error;
#[derive(Error, Debug)]
@ -70,12 +70,6 @@ pub enum BotError {
#[error("variables not yet supported")]
VariablesNotSupported,
#[error("database error")]
DatabaseError(#[from] sled::Error),
#[error("database migration error: {0}")]
SqliteError(#[from] migrator::MigrationError),
#[error("too many commands or message was too large")]
MessageTooLarge,