[−][src]Struct persy::OpenOptions
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]
F: Fn(&Persy) -> PRes<()> + 'static,
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]
F: Fn(&Vec<u8>) -> bool + 'static,
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]
P: AsRef<Path>,
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]
P: AsRef<Path>,
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]
fn default() -> OpenOptions
[src]
Auto Trait Implementations
impl !RefUnwindSafe for OpenOptions
impl !Send for OpenOptions
impl !Sync for OpenOptions
impl Unpin for OpenOptions
impl !UnwindSafe for OpenOptions
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, 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>,