pub trait CosmosEntity {
type Entity: Serialize;
// Required method
fn partition_key(&self) -> Self::Entity;
}Expand description
Re-export CosmosEntity which must be implemented by every model.
CosmosDB partition key. Every CosmosDB entity must implement it.
If you want to treat a Rust type as a document to be added to a Cosmos collection, you just need to implement this trait for your type. This specifies what you use as a partitioning key. You can read more about how partitioning works in Cosmos here.
§Example
struct MySampleStruct {
id: String,
string: String,
number: u64,
}
impl azure_data_cosmos::CosmosEntity for MySampleStruct {
type Entity = u64;
fn partition_key(&self) -> Self::Entity {
self.number
}
}Required Associated Types§
Required Methods§
Sourcefn partition_key(&self) -> Self::Entity
fn partition_key(&self) -> Self::Entity
Return partition key value as reference.
Implementations on Foreign Types§
Source§impl CosmosEntity for Value
impl CosmosEntity for Value
type Entity = Value
fn partition_key(&self) -> <Value as CosmosEntity>::Entity
Source§impl CosmosEntity for Box<ErasedCosmosEntityWrapper>
Implement CosmosEntity for a Boxed version.
impl CosmosEntity for Box<ErasedCosmosEntityWrapper>
Implement CosmosEntity for a Boxed version.