openiap_proto/
query.rs

1#![warn(missing_docs)]
2use super::openiap::{AggregateRequest, CountRequest, Envelope, InsertManyRequest, InsertOneRequest, UpdateOneRequest, InsertOrUpdateOneRequest, QueryRequest, DistinctRequest,
3    DeleteOneRequest, DeleteManyRequest, InsertOrUpdateManyRequest, UpdateDocumentRequest
4    };
5    impl QueryRequest {
6        /// Creates a new `QueryRequest` with the given `collectionname` and `query`.
7        #[tracing::instrument(skip_all)]
8        pub fn with_query(collectionname: &str, query: &str) -> Self {
9            Self {
10                collectionname: collectionname.to_string(),
11                query: query.to_string(),
12                ..Default::default()
13            }
14        }
15        /// Creates a new `QueryRequest` with the given `collectionname`, `query` and `projection`.
16        #[tracing::instrument(skip_all)]
17        pub fn with_projection(collectionname: &str, query: &str, projection: &str) -> Self {
18            Self {
19                collectionname: collectionname.to_string(),
20                query: query.to_string(),
21                projection: projection.to_string(),
22                ..Default::default()
23            }
24        }
25    }
26    impl QueryRequest {
27        /// Converts the `QueryRequest` to an `Envelope`.
28        #[tracing::instrument(skip_all)]
29        pub fn to_envelope(&self) -> Envelope {
30            let any_message = prost_types::Any {
31                type_url: "type.googleapis.com/openiap.QueryRequest".to_string(),
32                value: {
33                    let mut buf = Vec::new();
34                    prost::Message::encode(self, &mut buf).unwrap_or(());
35                    buf
36                },
37            };
38            Envelope {
39                command: "query".into(),
40                data: Some(any_message.clone()),
41                ..Default::default() 
42            }
43        }
44    }
45    impl AggregateRequest {
46        /// Creates a new `AggregateRequest` with the given `collectionname` and `pipeline`.
47        #[tracing::instrument(skip_all)]
48        pub fn to_envelope(&self) -> Envelope {
49            let any_message = prost_types::Any {
50                type_url: "type.googleapis.com/openiap.AggregateRequest".to_string(),
51                value: {
52                    let mut buf = Vec::new();
53                    prost::Message::encode(self, &mut buf).unwrap_or(());
54                    buf
55                },
56            };
57            Envelope {
58                command: "aggregate".into(),
59                data: Some(any_message.clone()),
60                ..Default::default() 
61            }
62        }
63    }
64    impl CountRequest {
65        /// Creates a new `CountRequest` with the given `collectionname` and `query`.
66        #[tracing::instrument(skip_all)]
67        pub fn to_envelope(&self) -> Envelope {
68            let any_message = prost_types::Any {
69                type_url: "type.googleapis.com/openiap.CountRequest".to_string(),
70                value: {
71                    let mut buf = Vec::new();
72                    prost::Message::encode(self, &mut buf).unwrap_or(());
73                    buf
74                },
75            };
76            Envelope {
77                command: "count".into(),
78                data: Some(any_message.clone()),
79                ..Default::default() 
80            }
81        }
82    }
83    impl DistinctRequest {
84        /// Creates a new `DistinctRequest` with the given `collectionname`, `field` and `query`.
85        #[tracing::instrument(skip_all)]
86        pub fn to_envelope(&self) -> Envelope {
87            let any_message = prost_types::Any {
88                type_url: "type.googleapis.com/openiap.DistinctRequest".to_string(),
89                value: {
90                    let mut buf = Vec::new();
91                    prost::Message::encode(self, &mut buf).unwrap_or(());
92                    buf
93                },
94            };
95            Envelope {
96                command: "distinct".into(),
97                data: Some(any_message.clone()),
98                ..Default::default() 
99            }
100        }
101    }
102    
103    impl InsertOneRequest {
104        /// Creates a new `InsertOneRequest` with the given `collectionname` and `document`.
105        #[tracing::instrument(skip_all)]
106        pub fn to_envelope(&self) -> Envelope {
107            let any_message = prost_types::Any {
108                type_url: "type.googleapis.com/openiap.InsertOneRequest".to_string(),
109                value: {
110                    let mut buf = Vec::new();
111                    prost::Message::encode(self, &mut buf).unwrap_or(());
112                    buf
113                },
114            };
115            Envelope {
116                command: "insertone".into(),
117                data: Some(any_message.clone()),
118                ..Default::default() 
119            }
120        }
121    }
122    impl InsertManyRequest {
123        /// Creates a new `InsertManyRequest` with the given `collectionname` and `documents`.
124        #[tracing::instrument(skip_all)]
125        pub fn to_envelope(&self) -> Envelope {
126            let any_message = prost_types::Any {
127                type_url: "type.googleapis.com/openiap.InsertManyRequest".to_string(),
128                value: {
129                    let mut buf = Vec::new();
130                    prost::Message::encode(self, &mut buf).unwrap_or(());
131                    buf
132                },
133            };
134            Envelope {
135                command: "insertmany".into(),
136                data: Some(any_message.clone()),
137                ..Default::default() 
138            }
139        }
140    }
141    impl UpdateOneRequest {
142        /// Creates a new `UpdateOneRequest` with the given `collectionname`, `filter` and `update`.
143        #[tracing::instrument(skip_all)]
144        pub fn to_envelope(&self) -> Envelope {
145            let any_message = prost_types::Any {
146                type_url: "type.googleapis.com/openiap.UpdateOneRequest".to_string(),
147                value: {
148                    let mut buf = Vec::new();
149                    prost::Message::encode(self, &mut buf).unwrap_or(());
150                    buf
151                },
152            };
153            Envelope {
154                command: "updateone".into(),
155                data: Some(any_message.clone()),
156                ..Default::default() 
157            }
158        }    
159    }
160    impl InsertOrUpdateOneRequest {
161        /// Creates a new `InsertOrUpdateOneRequest` with the given `collectionname`, `filter` and `update`.
162        #[tracing::instrument(skip_all)]
163        pub fn to_envelope(&self) -> Envelope {
164            let any_message = prost_types::Any {
165                type_url: "type.googleapis.com/openiap.InsertOrUpdateOneRequest".to_string(),
166                value: {
167                    let mut buf = Vec::new();
168                    prost::Message::encode(self, &mut buf).unwrap_or(());
169                    buf
170                },
171            };
172            Envelope {
173                command: "insertorupdateone".into(),
174                data: Some(any_message.clone()),
175                ..Default::default() 
176            }
177        }
178    }
179    impl  InsertOrUpdateManyRequest {
180        /// Creates a new `InsertOrUpdateManyRequest` with the given `collectionname`, `filter` and `update`.
181        #[tracing::instrument(skip_all)]
182        pub fn to_envelope(&self) -> Envelope {
183            let any_message = prost_types::Any {
184                type_url: "type.googleapis.com/openiap.InsertOrUpdateManyRequest".to_string(),
185                value: {
186                    let mut buf = Vec::new();
187                    prost::Message::encode(self, &mut buf).unwrap_or(());
188                    buf
189                },
190            };
191            Envelope {
192                command: "insertorupdatemany".into(),
193                data: Some(any_message.clone()),
194                ..Default::default() 
195            }
196        }    
197    }
198    impl  UpdateDocumentRequest {
199        /// Creates a new `UpdateDocumentRequest` with the given `collectionname`, `filter` and `update`.
200        #[tracing::instrument(skip_all)]
201        pub fn to_envelope(&self) -> Envelope {
202            let any_message = prost_types::Any {
203                type_url: "type.googleapis.com/openiap.UpdateDocumentRequest".to_string(),
204                value: {
205                    let mut buf = Vec::new();
206                    prost::Message::encode(self, &mut buf).unwrap_or(());
207                    buf
208                },
209            };
210            Envelope {
211                command: "updatedocument".into(),
212                data: Some(any_message.clone()),
213                ..Default::default() 
214            }
215        }        
216    }    
217    impl DeleteOneRequest {
218        /// Creates a new `DeleteOneRequest` with the given `collectionname`, `filter` and `update`.
219        #[tracing::instrument(skip_all)]
220        pub fn to_envelope(&self) -> Envelope {
221            let any_message = prost_types::Any {
222                type_url: "type.googleapis.com/openiap.DeleteOneRequest".to_string(),
223                value: {
224                    let mut buf = Vec::new();
225                    prost::Message::encode(self, &mut buf).unwrap_or(());
226                    buf
227                },
228            };
229            Envelope {
230                command: "deleteone".into(),
231                data: Some(any_message.clone()),
232                ..Default::default() 
233            }
234        }        
235    }
236    impl DeleteManyRequest {
237        /// Creates a new `DeleteManyRequest` with the given `collectionname`, `filter` and `update`.
238        #[tracing::instrument(skip_all)]
239        pub fn to_envelope(&self) -> Envelope {
240            let any_message = prost_types::Any {
241                type_url: "type.googleapis.com/openiap.DeleteManyRequest".to_string(),
242                value: {
243                    let mut buf = Vec::new();
244                    prost::Message::encode(self, &mut buf).unwrap_or(());
245                    buf
246                },
247            };
248            Envelope {
249                command: "deletemany".into(),
250                data: Some(any_message.clone()),
251                ..Default::default() 
252            }
253        }        
254    }