[−][src]Struct dodo::Directory
Storage backed by a folder.
Locking strategy
This storage locks entries while they are being read or writen to. Thus, readers and writers
should be dropped as soon as possible to prevent resource starvation. Note that multiple readers
are allowed at once on the same entry, like a RwLock
does.
Nothing prevents other programs from tempering with the files while they are locked, as the locks are only advisory locks. This storage will always check for locks before doing anything though.
Errors
All files in the folder are considered part of this storage. Thus, any unexpected event (denied permission, interrupted, ...) in the folder will result in an error.
It is expected that the folder remains valid as long a the storage exists. Tempering with the folder in any way (deleting it, moving it, removing permissions, ...) will result in an error.
Panics
A panic will occur if a file can't be locked or unlocked by this storage.
Methods
impl Directory
[src]
pub fn new<P>(path: P) -> Result<Self> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Create a new directory storage, or open it if it already exist. Folders are created recursively if needed.
Examples
use dodo::prelude::*; fn main() -> Result<(), Box<dyn std::error::Error>> { let directory = Directory::new(&path)?; Ok(()) }
Errors
This will return an error in the following situations :
- Folders didn't exists, and storage wasn't able to create it.
- Path points at a file, not a folder.
- Other IO specific errors (permission denied, invalid path, ...).
Trait Implementations
impl Clone for Directory
[src]
impl Debug for Directory
[src]
impl Storage for Directory
[src]
type Read = File
Reader.
type Write = File
Writer.
type Iterator = Iter
Iterator.
fn new(&mut self) -> Result<(Uuid, Self::Write)>
[src]
fn read(&self, entry: Uuid) -> Result<Self::Read>
[src]
fn write(&mut self, entry: Uuid) -> Result<Self::Write>
[src]
fn overwrite(&mut self, entry: Uuid) -> Result<Self::Write>
[src]
fn delete(&mut self, entry: Uuid) -> Result<()>
[src]
fn clear(&mut self) -> Result<()>
[src]
fn iter(&self) -> Result<Self::Iterator>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Directory
impl Send for Directory
impl Sync for Directory
impl Unpin for Directory
impl UnwindSafe for Directory
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,