[][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()?;

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

    let prepared = persy.prepare_commit(tx)?;
    persy.commit(prepared)?;

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

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

Methods

impl OpenOptions[src]

pub fn new() -> OpenOptions[src]

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

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

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

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

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

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

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

Trait Implementations

impl Default for OpenOptions[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for 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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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