Skip to content

Commit

Permalink
clippy my beloved
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinfuchs committed Mar 25, 2022
1 parent 3a71268 commit 2412556
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/database/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ pub type DatabaseResult<T> = Result<T, DatabaseError>;
#[derive(Debug, thiserror::Error)]
pub enum DatabaseError {
#[error("Database operation failed: {0}")]
SledError(sled::Error),
Sled(sled::Error),
#[error("Decrypting database value failed: {0} ")]
EncryptionError(aes_gcm::Error),
Encryption(aes_gcm::Error),
#[error("Encoding database value failed: {0} ")]
EncodingError(rmp_serde::encode::Error),
Encoding(rmp_serde::encode::Error),
#[error("Decoding database value failed: {0} ")]
DecodingError(rmp_serde::decode::Error)
Decoding(rmp_serde::decode::Error)
}

impl From<sled::Error> for DatabaseError {
fn from(e: Error) -> Self {
Self::SledError(e)
Self::Sled(e)
}
}

impl From<aes_gcm::Error> for DatabaseError {
fn from(e: aes_gcm::Error) -> Self {
Self::EncryptionError(e)
Self::Encryption(e)
}
}

impl From<rmp_serde::encode::Error> for DatabaseError {
fn from(e: rmp_serde::encode::Error) -> Self {
Self::EncodingError(e)
Self::Encoding(e)
}
}

impl From<rmp_serde::decode::Error> for DatabaseError {
fn from(e: rmp_serde::decode::Error) -> Self {
Self::DecodingError(e)
Self::Decoding(e)
}
}
6 changes: 2 additions & 4 deletions src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ impl Database {
let unix_now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let end_expiry = unix_now.as_nanos().to_be_bytes();

for entry in tree.range(start_expiry..end_expiry) {
if let Ok((_, paste_id)) = entry {
self.db.remove(paste_id)?;
}
for (_, paste_id) in tree.range(start_expiry..end_expiry).flatten() {
self.db.remove(paste_id)?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/routes/serve_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub async fn route_serve_frontend(path: web::Path<String>) -> impl Responder {
}

if let Some(file) = file {
let mime_type = get_mime_type_for_file(&Path::new(&path));
let mime_type = get_mime_type_for_file(Path::new(&path));
let body: Bytes = match file.data {
Cow::Borrowed(bytes) => bytes.into(),
Cow::Owned(bytes) => bytes.into(),
Expand Down

0 comments on commit 2412556

Please sign in to comment.