openiap_proto/
upload.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#![warn(missing_docs)]
use super::protos::{Envelope, UploadRequest, BeginStream, EndStream, Stream};
impl UploadRequest {
    /// Creates a new `UploadRequest` with the given `workitem`.
    pub fn filename(filename: &str) -> Self {
        Self {
            collectionname: "fs.files".to_string(),
            filename: filename.to_string(),
            ..Default::default()
        }
    }
    /// Creates a new `UploadRequest` with the given `workitem`.
    pub fn by_filename(collectionname: &str, filename: &str) -> Self {
        Self {
            collectionname: collectionname.to_string(),
            filename: filename.to_string(),
            ..Default::default()
        }
    }
}
impl UploadRequest {
    /// Creates a new `UploadRequest` with the given `workitem`.
    pub fn to_envelope(&self) -> Envelope {
        let any_message = prost_types::Any {
            type_url: "type.googleapis.com/openiap.UploadRequest".to_string(),
            value: {
                let mut buf = Vec::new();
                prost::Message::encode(self, &mut buf).unwrap_or(());
                buf
            },
        };
        Envelope {
            command: "upload".into(),
            data: Some(any_message.clone()),
            ..Default::default() 
        }
    }
}
impl BeginStream {
    /// Creates a new `BeginStream` with the given `workitem`.
    pub fn to_envelope(&self, rid:String) -> Envelope {
        let any_message = prost_types::Any {
            type_url: "type.googleapis.com/openiap.BeginStream".to_string(),
            value: {
                let mut buf = Vec::new();
                prost::Message::encode(self, &mut buf).unwrap_or(());
                buf
            },
        };
        Envelope {
            command: "beginstream".into(),
            data: Some(any_message.clone()),
            rid,
            ..Default::default() 
        }
    }
    /// Creates a new `BeginStream` with the given `workitem`.
    pub fn from_rid(rid:String) -> Envelope {
        let req = BeginStream {
            checksum: "".to_string(),
            ..Default::default()
        };
        let envelope = req.to_envelope(rid);
        let mut buf = Vec::new();
        prost::Message::encode(&envelope, &mut buf).unwrap_or(());
        envelope
    }   
}
impl EndStream {
    /// Creates a new `EndStream` with the given `workitem`.
    pub fn to_envelope(&self, rid:String) -> Envelope {
        let any_message = prost_types::Any {
            type_url: "type.googleapis.com/openiap.EndStream".to_string(),
            value: {
                let mut buf = Vec::new();
                prost::Message::encode(self, &mut buf).unwrap_or(());
                buf
            },
        };
        Envelope {
            command: "endstream".into(),
            data: Some(any_message.clone()),
            rid,
            ..Default::default() 
        }
    }
    /// Creates a new `EndStream` with the given `workitem`.
    pub fn from_rid(rid:String) -> Envelope {
        let req = EndStream {            
        };
        let envelope = req.to_envelope(rid);
        let mut buf = Vec::new();
        prost::Message::encode(&envelope, &mut buf).unwrap_or(());
        envelope
    }   
}
impl Stream {
    /// Creates a new `Stream` with the given `workitem`.
    pub fn to_envelope(&self, rid:String) -> Envelope {
        let any_message = prost_types::Any {
            type_url: "type.googleapis.com/openiap.Stream".to_string(),
            value: {
                let mut buf = Vec::new();
                prost::Message::encode(self, &mut buf).unwrap_or(());
                buf
            },
        };
        Envelope {
            command: "stream".into(),
            data: Some(any_message.clone()),
            rid,
            ..Default::default() 
        }
    }
    /// Creates a new `Stream` with the given `workitem`.
    pub fn from_rid(data: Vec<u8>, rid:String) -> Envelope {
        let req = Stream {
            data
        };
        let envelope = req.to_envelope(rid);
        let mut buf = Vec::new();
        prost::Message::encode(&envelope, &mut buf).unwrap_or(());
        envelope
    }    
}