Collection

Trait Collection 

Source
pub trait Collection{
    // Provided methods
    fn collection_name() -> String { ... }
    fn put_into_collection(
        &self,
        db: &DbConnection,
        new_key: &str,
    ) -> Result<()> { ... }
    fn get_from_collection(db: &DbConnection, obj_key: &str) -> Result<Self> { ... }
    fn del_from_collection(db: &DbConnection, obj_key: &str) -> Result<()> { ... }
    fn remove_collection(db: &DbConnection) -> Result<()> { ... }
    fn list_collection(db: &DbConnection) -> Result<Vec<Self>> { ... }
    fn collection_size(db: &DbConnection) -> Result<i64> { ... }
}

Provided Methods§

Source

fn collection_name() -> String

Return an unique name as the container for your data.

Source

fn put_into_collection(&self, db: &DbConnection, new_key: &str) -> Result<()>

Put the object into collection with an associated key. If new_key already exits, the database will attempt to replace the offending row instead.

Source

fn get_from_collection(db: &DbConnection, obj_key: &str) -> Result<Self>

Return the object in this collection by key.

Source

fn del_from_collection(db: &DbConnection, obj_key: &str) -> Result<()>

Delete the object in this collection by key.

Source

fn remove_collection(db: &DbConnection) -> Result<()>

Remove all objects in this collection.

Source

fn list_collection(db: &DbConnection) -> Result<Vec<Self>>

List all items in the collection.

Source

fn collection_size(db: &DbConnection) -> Result<i64>

Return the number of items in collection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§