Struct rustbreak::backend::FileBackend
source · [−]pub struct FileBackend(_);
Expand description
A backend using a file.
Implementations
sourceimpl FileBackend
impl FileBackend
sourceimpl FileBackend
impl FileBackend
sourcepub fn from_path_or_fail<P: AsRef<Path>>(path: P) -> BackendResult<Self>
pub fn from_path_or_fail<P: AsRef<Path>>(path: P) -> BackendResult<Self>
Opens a new FileBackend
for a given path.
Errors when the file doesn’t yet exist.
sourcepub fn from_path_or_create<P: AsRef<Path>>(
path: P
) -> BackendResult<(Self, bool)>
pub fn from_path_or_create<P: AsRef<Path>>(
path: P
) -> BackendResult<(Self, bool)>
Opens a new FileBackend
for a given path.
Creates a file if it doesn’t yet exist.
Returns the FileBackend
and whether the file already existed.
sourcepub fn from_path_or_create_and<P, C>(path: P, closure: C) -> BackendResult<Self> where
C: FnOnce(&mut File),
P: AsRef<Path>,
pub fn from_path_or_create_and<P, C>(path: P, closure: C) -> BackendResult<Self> where
C: FnOnce(&mut File),
P: AsRef<Path>,
Opens a new FileBackend
for a given path.
Creates a file if it doesn’t yet exist, and calls closure
with it.
Trait Implementations
sourceimpl Backend for FileBackend
impl Backend for FileBackend
sourcefn get_data(&mut self) -> BackendResult<Vec<u8>>
fn get_data(&mut self) -> BackendResult<Vec<u8>>
Read the all data from the backend.
sourcefn put_data(&mut self, data: &[u8]) -> BackendResult<()>
fn put_data(&mut self, data: &[u8]) -> BackendResult<()>
Write the whole slice to the backend.
Auto Trait Implementations
impl RefUnwindSafe for FileBackend
impl Send for FileBackend
impl Sync for FileBackend
impl Unpin for FileBackend
impl UnwindSafe for FileBackend
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more