Struct sbd::storage::FilesystemStorage [] [src]

pub struct FilesystemStorage<P: AsRef<Path>> {
    // some fields omitted
}

A structure for managing storing and retriving SBD messages on a filesystem.

Messages are stored in a directory hierarchy under a single root directory. Message storage and retrieval are managed by a Storage object, which is configured for a single root directory.

Methods

impl<P: AsRef<Path>> Storage<P>
[src]

fn open(root: P) -> Result<Storage<P>>

Opens a new storage for a given directory.

Errors

If the directory does not exist, returns an NotADirectory error.

Examples

use sbd::storage::FilesystemStorage;
let storage = FilesystemStorage::open("data").unwrap();
assert!(FilesystemStorage::open("not/a/directory").is_err());

fn iter(&self) -> StorageIterator

Returns a StorageIterator over the messages in this storage.

Examples

use sbd::storage::FilesystemStorage;
for message in FilesystemStorage::open("data").unwrap().iter() {
    println!("{:?}", message);
}

Trait Implementations

impl<P: Debug + AsRef<Path>> Debug for Storage<P>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<P: AsRef<Path>> Storage for Storage<P>
[src]

fn store(&mut self, message: &Message) -> Result<()>

Stores a message on the filesystem.

Examples

use sbd::storage::{FilesystemStorage, Storage};
use sbd::mo::Message;
let message: Message = Default::default();
let storage = FilesystemStorage::open("/var/iridium").unwrap();
storage.store(&message);