powerplatform_dataverse_service_client/
entity.rs

1use serde::{Serialize, de::DeserializeOwned};
2
3use crate::{reference::Reference, select::Select};
4
5/**
6Supertrait for entities that can be retrieved from a Microsoft
7Dataverse environment
8
9This should be implemented by data structures you want to use with
10the following functions in `Client`:
11- `retrieve(...)`
12- `retrieve_multiple(...)`
13
14# Examples
15```rust
16use serde::Deserialize;
17use uuid::Uuid;
18use powerplatform_dataverse_service_client::{
19    entity::ReadEntity,
20    select::Select
21};
22
23#[derive(Deserialize)]
24struct Contact {
25    contactid: Uuid,
26    firstname: String,
27    lastname: String,
28}
29
30impl ReadEntity for Contact {}
31
32impl Select for Contact {
33    fn get_columns() -> &'static [&'static str] {
34        &["contactid", "firstname", "lastname"]
35    }
36}
37```
38*/
39pub trait ReadEntity: DeserializeOwned + Select {}
40
41/**
42Supertrait for entities that can be written into a Microsoft
43Dataverse environment
44
45This should be implemented by data structures you want to use with
46the following functions in `Client`:
47- `create(...)`
48- `update(...)`
49- `upsert(...)`
50
51# Examples
52```rust
53use serde::Serialize;
54use uuid::Uuid;
55use powerplatform_dataverse_service_client::{
56    entity::WriteEntity,
57    reference::{Reference, ReferenceStruct}
58};
59
60#[derive(Serialize)]
61struct Contact {
62    contactid: Uuid,
63    firstname: String,
64    lastname: String,
65}
66
67impl WriteEntity for Contact {}
68
69impl Reference for Contact {
70    fn get_reference(&self) -> ReferenceStruct {
71        ReferenceStruct::new(
72            "contacts",
73            self.contactid,
74        )
75    }
76}
77```
78*/
79pub trait WriteEntity: Serialize + Reference {}