openiap_proto/
download.rs

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