Add truncate method to DatabaseStorage trait

This commit is contained in:
PThorpe92
2025-07-17 11:34:08 -04:00
committed by Jussi Saurio
parent 8bf2898c47
commit 73fe4ffa06

View File

@@ -18,6 +18,7 @@ pub trait DatabaseStorage: Send + Sync {
) -> Result<Completion>;
fn sync(&self, c: Completion) -> Result<Completion>;
fn size(&self) -> Result<u64>;
fn truncate(&self, len: u64, c: Completion) -> Result<()>;
}
#[cfg(feature = "fs")]
@@ -69,6 +70,12 @@ impl DatabaseStorage for DatabaseFile {
fn size(&self) -> Result<u64> {
self.file.size()
}
#[instrument(skip_all, level = Level::INFO)]
fn truncate(&self, len: u64, c: Completion) -> Result<()> {
self.file.truncate(len, c)?;
Ok(())
}
}
#[cfg(feature = "fs")]
@@ -122,6 +129,12 @@ impl DatabaseStorage for FileMemoryStorage {
fn size(&self) -> Result<u64> {
self.file.size()
}
#[instrument(skip_all, level = Level::INFO)]
fn truncate(&self, len: u64, c: Completion) -> Result<()> {
let _ = self.file.truncate(len, c)?;
Ok(())
}
}
impl FileMemoryStorage {