Skip to main content

StdStorage

Struct StdStorage 

Source
pub struct StdStorage { /* private fields */ }
Expand description

A WalStorage backend that maps file names to a directory on the local filesystem.

Implementations§

Source§

impl StdStorage

Source

pub fn new(dir: impl AsRef<Path>) -> Result<Self>

Creates a new StdStorage rooted at the given directory.

The directory is created if it does not exist.

§Errors

Returns an error if the directory cannot be created.

Source

pub fn dir(&self) -> &Path

Returns the directory path this storage is rooted at.

Trait Implementations§

Source§

impl WalStorage for StdStorage

Source§

type Error = Error

Error type returned by storage operations.
Source§

fn read_file(&self, name: &str) -> Result<Vec<u8>, Self::Error>

Reads the entire contents of the named file. Read more
Source§

fn write_file(&mut self, name: &str, data: &[u8]) -> Result<(), Self::Error>

Creates or overwrites a file with the given contents. Read more
Source§

fn append_file(&mut self, name: &str, data: &[u8]) -> Result<(), Self::Error>

Appends data to an existing file (or creates it). Read more
Source§

fn remove_file(&mut self, name: &str) -> Result<(), Self::Error>

Removes a file. Implementations should not error if the file does not exist. Read more
Source§

fn list_files(&self, suffix: &str) -> Result<Vec<String>, Self::Error>

Lists all file names that end with suffix, sorted. Read more
Source§

fn sync_file(&mut self, name: &str) -> Result<(), Self::Error>

Ensures buffered data for the named file is durably persisted. Read more
Source§

fn rename_file(&mut self, from: &str, to: &str) -> Result<(), Self::Error>

Atomically replaces to with from. Read more
Source§

fn file_size(&self, name: &str) -> Result<u64, Self::Error>

Returns the size of the named file in bytes. Read more
Source§

fn file_exists(&self, name: &str) -> bool

Returns true if the named file exists.
Source§

fn read_file_range( &self, name: &str, offset: usize, len: usize, ) -> Result<Vec<u8>, Self::Error>

Reads a byte range from the named file. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.