Skip to content

Commit

Permalink
storage: remove Display bound on Engine trait
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Jun 10, 2024
1 parent e1e228b commit 4c770d1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
8 changes: 1 addition & 7 deletions src/storage/bitcask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ impl BitCask {
}
}

impl std::fmt::Display for BitCask {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "bitcask")
}
}

impl Engine for BitCask {
type ScanIterator<'a> = ScanIterator<'a>;

Expand Down Expand Up @@ -150,7 +144,7 @@ impl Engine for BitCask {
let live_disk_size = size + 8 * keys; // account for length prefixes
let garbage_disk_size = total_disk_size - live_disk_size;
Ok(Status {
name: self.to_string(),
name: "bitcask".to_string(),
keys,
size,
total_disk_size,
Expand Down
9 changes: 1 addition & 8 deletions src/storage/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
/// Only supports single-threaded use since all methods (including reads) take a
/// mutable reference -- serialized access can't be avoided anyway, since both
/// Raft execution and file access is serial.
pub trait Engine: std::fmt::Display + Send {
pub trait Engine: Send {
/// The iterator returned by scan().
type ScanIterator<'a>: ScanIterator + 'a
where
Expand Down Expand Up @@ -101,13 +101,6 @@ pub mod test {
Set { key: Vec<u8>, value: Vec<u8> },
}

impl<E: Engine> std::fmt::Display for Emit<E> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// Just dispatch to the inner engine.
self.inner.fmt(f)
}
}

impl<E: Engine> Emit<E> {
pub fn new(inner: E, tx: Sender<Operation>) -> Self {
Self { inner, tx }
Expand Down
8 changes: 1 addition & 7 deletions src/storage/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ impl Memory {
}
}

impl std::fmt::Display for Memory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "memory")
}
}

impl Engine for Memory {
type ScanIterator<'a> = ScanIterator<'a>;

Expand Down Expand Up @@ -54,7 +48,7 @@ impl Engine for Memory {

fn status(&mut self) -> Result<Status> {
Ok(Status {
name: self.to_string(),
name: "memory".to_string(),
keys: self.data.len() as u64,
size: self.data.iter().fold(0, |size, (k, v)| size + k.len() as u64 + v.len() as u64),
total_disk_size: 0,
Expand Down

0 comments on commit 4c770d1

Please sign in to comment.