openiap_proto/
signin.rs

1#![warn(missing_docs)]
2use super::openiap::{Envelope, SigninRequest};
3
4impl SigninRequest {
5    /// Creates a new `SigninRequest` with the given `username` and `password`.
6    pub fn with_userpass(username: &str, password: &str) -> Self {
7        Self {
8            username: username.to_string(),
9            password: password.to_string(),
10            ping: true,
11            ..Default::default()
12        }
13    }
14    /// Creates a new `SigninRequest` with the given `jwt`.
15    pub fn with_jwt(jwt: &str) -> Self {
16        Self {
17            jwt: jwt.to_string(),
18            ..Default::default()
19        }
20    }
21}
22impl SigninRequest {
23    /// Converts the `SigninRequest` to an `Envelope`.
24    pub fn to_envelope(&self) -> Envelope {
25        let any_message = prost_types::Any {
26            type_url: "type.googleapis.com/openiap.SigninRequest".to_string(),
27            value: {
28                let mut buf = Vec::new();
29                prost::Message::encode(self, &mut buf).unwrap_or(());
30                buf
31            },
32        };
33        Envelope {
34            command: "signin".into(),
35            data: Some(any_message.clone()),
36            ..Default::default() 
37        }
38    }
39}