Skip to content

Commit

Permalink
Implement fmt::Debug trait on Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Aug 22, 2024
1 parent 59a0907 commit 616b534
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ pub enum StorageError {
/// Different implementation can cache the files differently, or not at all.
/// Implementations are free to assume files are never overwritten.
#[async_trait]
pub trait Storage {
pub trait Storage: fmt::Debug {
async fn fetch_structure(
&self,
id: &ObjectId,
Expand Down Expand Up @@ -767,13 +767,6 @@ pub trait Storage {
async fn write_chunk(&self, id: ObjectId, bytes: Bytes) -> Result<(), StorageError>;
}

impl fmt::Debug for dyn Storage + Send + Sync {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
// FIXME
write!(f, "Storage")
}
}

#[derive(Clone, Debug)]
pub struct Dataset {
storage: Arc<dyn Storage + Send + Sync>,
Expand Down
13 changes: 13 additions & 0 deletions src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use base64::{engine::general_purpose::URL_SAFE as BASE64_URL_SAFE, Engine as _};
use std::{
collections::HashMap,
fmt,
fs::create_dir_all,
ops::Range,
sync::{Arc, RwLock},
Expand Down Expand Up @@ -108,6 +109,11 @@ impl ObjectStorage {
}
}

impl fmt::Debug for ObjectStorage {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "ObjectStorage, prefix={}, store={}", self.prefix, self.store)
}
}
#[async_trait]
impl Storage for ObjectStorage {
async fn fetch_structure(
Expand Down Expand Up @@ -221,6 +227,13 @@ impl InMemoryStorage {
}
}

impl fmt::Debug for InMemoryStorage {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
// FIXME
write!(f, "InMemoryStorage")
}
}

#[async_trait]
impl Storage for InMemoryStorage {
async fn fetch_structure(
Expand Down

0 comments on commit 616b534

Please sign in to comment.