pub trait Collectionwhere
Self: Serialize + DeserializeOwned,{
// 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§
Sourcefn collection_name() -> String
fn collection_name() -> String
Return an unique name as the container for your data.
Sourcefn put_into_collection(&self, db: &DbConnection, new_key: &str) -> Result<()>
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.
Sourcefn get_from_collection(db: &DbConnection, obj_key: &str) -> Result<Self>
fn get_from_collection(db: &DbConnection, obj_key: &str) -> Result<Self>
Return the object in this collection by key.
Sourcefn del_from_collection(db: &DbConnection, obj_key: &str) -> Result<()>
fn del_from_collection(db: &DbConnection, obj_key: &str) -> Result<()>
Delete the object in this collection by key.
Sourcefn remove_collection(db: &DbConnection) -> Result<()>
fn remove_collection(db: &DbConnection) -> Result<()>
Remove all objects in this collection.
Sourcefn list_collection(db: &DbConnection) -> Result<Vec<Self>>
fn list_collection(db: &DbConnection) -> Result<Vec<Self>>
List all items in the collection.
Sourcefn collection_size(db: &DbConnection) -> Result<i64>
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.