[][src]Struct persy::OpenOptions

pub struct OpenOptions { /* fields omitted */ }

Options, flags, configs which can be used to configure how a persy database is opened.

use persy::{OpenOptions, Persy, PersyId, PRes, ValueMode};

// This function will only be called on database creation
fn init(persy: &Persy) -> PRes<()> {
    let mut tx = persy.begin()?;

    tx.create_segment("data")?;
    tx.create_index::<u64, PersyId>("index", ValueMode::REPLACE)?;

    let prepared = tx.prepare()?;
    prepared.commit()?;

    println!("Segment and Index successfully created");
    Ok(())
}

let persy = OpenOptions::new().create(true).prepare_with(init).open("target/persy.db")?;

Implementations

impl OpenOptions[src]

pub fn new() -> OpenOptions[src]

pub fn truncate(&mut self, truncate: bool) -> &mut OpenOptions[src]

Truncate the file on open removing all the persistent data

pub fn create(&mut self, create: bool) -> &mut OpenOptions[src]

Create a new file if not exists

pub fn create_new(&mut self, create_new: bool) -> &mut OpenOptions[src]

Create a new file if exists fail

pub fn prepare_with<F>(&mut self, prepare: F) -> &mut OpenOptions where
    F: Fn(&Persy) -> PRes<()> + 'static, 
[src]

Provide a function for initialize the storage in case did not existed

pub fn recover_with<F>(&mut self, recover: F) -> &mut OpenOptions where
    F: Fn(&Vec<u8>) -> bool + 'static, 
[src]

Provide a function for check if a transaction must be committed or rollback in case of recover from crash

pub fn config(&mut self, config: Config) -> &mut OpenOptions[src]

Provide general storage configurations

pub fn recover<P>(&mut self, path: P) -> PRes<Recover> where
    P: AsRef<Path>, 
[src]

Open a file to a recover structure to list pending transactions and select witch commit and rollback

pub fn open<P>(&mut self, path: P) -> PRes<Persy> where
    P: AsRef<Path>, 
[src]

Open a file from the given path with the current options

pub fn memory(&mut self) -> PRes<Persy>[src]

Create a persy instance backed by a Vec<u8> with no persistence

Trait Implementations

impl Default for OpenOptions[src]

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, 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>,