openiap_proto/
download.rs1#![warn(missing_docs)]
2use super::protos::{Envelope, DownloadRequest};
3impl DownloadRequest {
4 #[tracing::instrument(skip_all)]
6 pub fn id(id: &str) -> Self {
7 Self {
8 collectionname: "fs.files".to_string(),
9 id: id.to_string(),
10 ..Default::default()
11 }
12 }
13 #[tracing::instrument(skip_all)]
15 pub fn by_id(collectionname: &str, id: &str) -> Self {
16 Self {
17 collectionname: collectionname.to_string(),
18 id: id.to_string(),
19 ..Default::default()
20 }
21 }
22 #[tracing::instrument(skip_all)]
24 pub fn by_filename(collectionname: &str, filename: &str) -> Self {
25 Self {
26 collectionname: collectionname.to_string(),
27 filename: filename.to_string(),
28 ..Default::default()
29 }
30 }
31}
32impl DownloadRequest {
33 #[tracing::instrument(skip_all)]
35 pub fn to_envelope(&self) -> Envelope {
36 let any_message = prost_types::Any {
37 type_url: "type.googleapis.com/openiap.DownloadRequest".to_string(),
38 value: {
39 let mut buf = Vec::new();
40 prost::Message::encode(self, &mut buf).unwrap_or(());
41 buf
42 },
43 };
44 Envelope {
45 command: "download".into(),
46 data: Some(any_message.clone()),
47 ..Default::default()
48 }
49 }
50}