[−][src]Struct ejdb::CollectionOptions
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]
self,
db: &Database,
name: S
) -> Result<Collection>
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]
fn eq(&self, other: &CollectionOptions) -> bool
[src]
fn ne(&self, other: &CollectionOptions) -> bool
[src]
impl Default for CollectionOptions
[src]
fn default() -> CollectionOptions
[src]
impl Clone for CollectionOptions
[src]
fn clone(&self) -> 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]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,