[][src]Struct ejdb::CollectionOptions

pub struct CollectionOptions {
    pub large: bool,
    pub compressed: bool,
    pub records: i64,
    pub cached_records: i32,
}

Represents a set of options of an EJDB collection.

Used when new collections are created. It is not possible to change options of a created collection.

This is a builder object, so you can chain method calls to set various options. Finally, you can create a collection with these options with get_or_create() method.

Example

let options = CollectionOptions::default()
    .large(true)
    .compressed(true)
    .records(1_024_000)
    .cached_records(1024);

Fields

large: bool

Make the collection "large", i.e. able to hold more than 2GB of data. Default is false.

compressed: bool

Compress records in the collection with DEFLATE. Default is false.

records: i64

Expected number of records in the collection. Default is 128 000.

cached_records: i32

Maximum number of records cached in memory. Default is 0.

Methods

impl CollectionOptions[src]

pub fn large(self, large: bool) -> CollectionOptions[src]

pub fn compressed(self, compressed: bool) -> CollectionOptions[src]

pub fn records(self, records: i64) -> CollectionOptions[src]

pub fn cached_records(self, cached_records: i32) -> CollectionOptions[src]

pub fn get_or_create<S: Into<Vec<u8>>>(
    self,
    db: &Database,
    name: S
) -> Result<Collection>
[src]

Invokes db.collection_with_options(name, options) with this object as an argument.

This is a convenience method which allows setting options and creating a collection in one go. Remember that if collection with the specified name already exists, it will be returned and options will be ignored.

name argument can be of any type which is convertible to a vector of bytes, like string or byte slice.

Example

let db = Database::open("/path/to/db").unwrap();
let coll = CollectionOptions::default()
    .large(true).compressed(true)
    .records(1_024_000).cached_records(1024)
    .get_or_create(&db, "new_collection").unwrap();
// work with the collection

Trait Implementations

impl PartialEq<CollectionOptions> for CollectionOptions[src]

impl Default for CollectionOptions[src]

impl Clone for CollectionOptions[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for CollectionOptions[src]

impl Debug for CollectionOptions[src]

Auto Trait Implementations

impl Send for CollectionOptions

impl Sync for CollectionOptions

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]