mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
Add truncate method to DatabaseStorage trait
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user