[][src]Struct dodo::storage::Directory

pub struct Directory { /* fields omitted */ }

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]

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.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,