From d53ee8ab5c6cdb47df150926fc6826e0dca224b4 Mon Sep 17 00:00:00 2001 From: KubaWis Date: Sun, 23 Feb 2025 18:19:22 +0100 Subject: [PATCH] Initial commit --- Cargo.toml | 19 + src/constants.rs | 14 + src/main.rs | 54 + src/miband8.rs | 333 + src/protobuf_decoder.rs | 112 + src/xiaomi.rs | 29681 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 30213 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/constants.rs create mode 100644 src/main.rs create mode 100644 src/miband8.rs create mode 100644 src/protobuf_decoder.rs create mode 100644 src/xiaomi.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a81b5c2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "miband8-hr" +version = "0.1.0" +edition = "2021" + +[dependencies] +aes = "0.8.4" +btleplug = "0.11.6" +ccm = "0.5.0" +futures = "0.3.31" +hex = "0.4.3" +hmac = "0.12.1" +protobuf = "3.7.1" +rand = "0.8.5" +rand_core = "0.6.4" +rosc = "0.10.1" +sha2 = "0.10.8" +tokio = {version="1.41.0", features = ["full"]} +uuid = "1.11.0" diff --git a/src/constants.rs b/src/constants.rs new file mode 100644 index 0000000..4b60520 --- /dev/null +++ b/src/constants.rs @@ -0,0 +1,14 @@ + +// https://github.com/VladKolerts/miband4/blob/master/constants.js +// https://github.com/vshymanskyy/miband-js/blob/master/src/miband.js + +pub const PAYLOAD_ACK: [u8;4] = [0x0,0x0,0x3,0x0]; + +pub const MIBAND8: &str = "0000fe95-0000-1000-8000-00805f9b34fb"; + +pub const READ: &str = "00000051-0000-1000-8000-00805f9b34fb"; +pub const WRITE: &str = "00000052-0000-1000-8000-00805f9b34fb"; +pub const ACTIVITY_DATA: &str = "00000053-0000-1000-8000-00805f9b34fb"; +pub const DATA_UPLOAD: &str = "00000055-0000-1000-8000-00805f9b34fb"; + +pub const AUTH_COMMAND: &[u8] = &[0x00, 0x00, 0x02, 0x02, 0x08, 0x01, 0x10, 0x1a, 0x1a, 0x15, 0xf2, 0x01, 0x12, 0x0a, 0x10]; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..fbc2e9a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,54 @@ +mod constants; +mod miband8; +mod xiaomi; +mod protobuf_decoder; + +use std::{net::{SocketAddrV4, UdpSocket}, str::FromStr}; +use rosc::{encoder, OscMessage, OscPacket, OscType}; +use tokio::{sync::watch, task}; + +const SEND_TO_CHAT: bool = false; +const SEND_ADDR: &str = "10.42.0.2:9000"; + +#[tokio::main] +async fn main() { + let send_addr: SocketAddrV4 = SocketAddrV4::from_str(SEND_ADDR).unwrap(); + + + let sock = UdpSocket::bind(SocketAddrV4::from_str("0.0.0.0:9000").unwrap()).unwrap(); + + let (tx, mut rx) = watch::channel::(0); + + let mut band = miband8::Miband8::new("f60b07bd3739018d7ee61d866c1eb01d".to_owned()); + let e = band.init().await; + println!("{:?}", e); + task::spawn(async move { + band.continuously_measure_hr(tx).await; + }); + while rx.changed().await.is_ok() { + let hr = rx.borrow_and_update().clone(); + println!("Got heartrate: {}", hr); + + if SEND_TO_CHAT { + let msg_buf = encoder::encode(&OscPacket::Message(OscMessage { + addr: "/chatbox/input".to_string(), + args: vec![OscType::String(format!("<3 {hr} bpm").to_string()), rosc::OscType::Bool(true),rosc::OscType::Bool(false)], + })) + .unwrap(); + + sock.send_to(&msg_buf, send_addr).unwrap(); + } + let param_names = vec!["/avatar/parameters/VF101_beat", "/avatar/parameters/VF142_beat", "/avatar/parameters/VF145_beat"]; + for param in param_names { + let msg_buf = encoder::encode(&OscPacket::Message(OscMessage { + addr: param.to_string(), + args: vec![OscType::Float((hr as f32 - 127.0)/ 127.0)], + })) + .unwrap(); + + sock.send_to(&msg_buf, send_addr).unwrap(); + } + } + + +} diff --git a/src/miband8.rs b/src/miband8.rs new file mode 100644 index 0000000..3b4df34 --- /dev/null +++ b/src/miband8.rs @@ -0,0 +1,333 @@ +use std::collections::HashMap; +use std::{error::Error, time::Duration, vec}; + +use btleplug::{api::{Characteristic, Service,Central, Manager as _, Peripheral as _, ScanFilter, WriteType}, platform::{self, Adapter, Peripheral}}; + +use futures::StreamExt; +use hmac::{Hmac, Mac}; + +use rand::Rng; +use tokio::sync::watch::Sender; +use tokio::time; +use uuid::uuid; + +use aes::Aes128; +use sha2::Sha256; +use ccm::{aead::{generic_array::GenericArray, Aead,KeyInit as ccm_key},consts::{U4, U12},Ccm}; + +use crate::constants::{self, AUTH_COMMAND}; +use crate::protobuf_decoder::{self, Value}; + +type HmacSha256 = Hmac; +type Aes128Ccm = Ccm; + +pub struct Miband8 { + dev: Option, + central: Option, + auth_key: String, + services: HashMap, + chars: HashMap, + nonce: Vec, + encryption_nonce: Vec, + encryption_key: Vec, + decryption_nonce: Vec, + decryption_key: Vec, + handle: u8 +} + +impl Miband8 { + pub fn new(key: String) -> Self { + Miband8 { + dev: None, + central: None, + auth_key: key, + services: HashMap::new(), + chars: HashMap::new(), + nonce: [0;16].to_vec(), + encryption_nonce: vec![], + encryption_key: vec![], + decryption_nonce: vec![], + decryption_key: vec![], + handle: 2 + } + } + + pub async fn init(&mut self) -> Result<(), Box> { + let manager = platform::Manager::new().await?; + + // get the first bluetooth adapter + let adapters = manager.adapters().await?; + let central = adapters.into_iter().nth(0); + if central.is_none() { + return Err("No bluetooth adapter found")?; + } + + self.central = Some(central.unwrap()); + + // start scanning for devices + self.central.as_ref().unwrap() + .start_scan(ScanFilter { + services: vec![uuid!(constants::MIBAND8)], + }) + .await?; + + + time::sleep(Duration::from_secs(5)).await; + + let mut band_op: Option = None; + for p in self.central.as_ref().unwrap().peripherals().await? { + if p.properties() + .await? + .unwrap() + .local_name + .iter() + .any(|name| name.contains("Xiaomi Smart Band 8")) + { + band_op = Some(p); + } + } + + if band_op.is_none() { + return Err("No band found")?; + } + + let band = band_op.unwrap(); + + println!("Connecting to GATT"); + band.connect().await?; + println!("Connected to GATT"); + + // discover services and characteristics + band.discover_services().await?; + println!("Discovered services"); + + self.dev = Some(band.clone()); + + let chars = band.services(); + self.services.insert( + "miband8".to_owned(), + chars + .iter() + .find(|c| c.uuid == uuid!(constants::MIBAND8)) + .unwrap().to_owned(), + ); + println!("Services initialized"); + + + let miband8_chars = &self.services + .get("miband8") + .unwrap() + .characteristics; + + self.chars.insert( + "activity_data".to_owned(), + miband8_chars.iter() + .find(|c| c.uuid == uuid!(constants::ACTIVITY_DATA)) + .unwrap().to_owned(), + ); + + self.chars.insert( + "read".to_owned(), + miband8_chars.iter() + .find(|c| c.uuid == uuid!(constants::READ)) + .unwrap().to_owned(), + ); + + self.chars.insert( + "write".to_owned(), + miband8_chars.iter() + .find(|c| c.uuid == uuid!(constants::WRITE)) + .unwrap().to_owned(), + ); + + self.chars.insert( + "data_upload".to_owned(), + miband8_chars.iter() + .find(|c| c.uuid == uuid!(constants::DATA_UPLOAD)) + .unwrap().to_owned(), + ); + println!("Characteristics initialized"); + + band.subscribe(&self.chars["write"]).await?; + band.subscribe(&self.chars["read"]).await?; + band.subscribe(&self.chars["activity_data"]).await?; + band.subscribe(&self.chars["data_upload"]).await?; + + // Send AUTH step 1: auth_command + nonce + rand::thread_rng().fill(&mut self.nonce[..]); + band.write(&self.chars.get("write").unwrap(), &[AUTH_COMMAND, &self.nonce.clone()].concat(), WriteType::WithoutResponse).await?; + + let mut events = band.notifications().await?; + while let Some(event) = events.next().await { + if event.uuid == uuid!(constants::WRITE) && event.value == constants::PAYLOAD_ACK { + println!("Got ack"); + // TODO: wait for ack before sending another command + } + if event.uuid == uuid!(constants::READ) && event.value[5] == 0x01 { + self.ack().await?; + match event.value[7] { + // NONCE + 0x1A => { + println!("Got watch nonce"); + let next_packet: Vec = self.handle_watch_nonce(&event.value).await?; + band.write(&self.chars.get("write").unwrap(), &next_packet, WriteType::WithoutResponse).await?; + } + // Auth success + 0x1B => { + println!("Authenticated!!"); + return Ok(()); + } + unk => { + println!("Unknown command subtype: {:2X?}", unk) + } + } + } + } + Ok(()) + } + + async fn ack(&mut self) -> Result<(), btleplug::Error> { + self.dev.as_ref().unwrap().write(&self.chars.get("read").unwrap(), &constants::PAYLOAD_ACK, WriteType::WithoutResponse).await + } + + fn get_handle(&mut self) -> u8{ + self.handle = self.handle.wrapping_add(1); + self.handle + } + + pub async fn continuously_measure_hr(&mut self, channel_tx: Sender) -> u8 { + let command: Vec = vec![0x08, 0x08, 0x10, 0x2d]; + let handle = self.get_handle(); + let mut command_enc = vec![0x00, 0x00, 0x02, 0x01, handle, 0x00]; + command_enc.append(&mut self.encrypt(self.encryption_key.clone(), &mut self.encryption_nonce.clone(), command, handle)); + self.dev.as_ref().unwrap().write(&self.chars.get("write").unwrap(), &command_enc, WriteType::WithoutResponse).await.unwrap(); + + let mut events2 = self.dev.as_ref().unwrap().notifications().await.unwrap(); + while let Some(event) = events2.next().await { + self.ack().await.unwrap(); + let decrypted = self.decrypt(event.value[4..event.value.len()].to_vec()); + if decrypted.len() > 8 { + let parsed = protobuf_decoder::Decoder::decode(&decrypted[..decrypted.len()-8].to_vec()); + if let Some(Value::PROTOBUF(activity_update)) = parsed.values.get(&10) { // 10 ID for RealTimeStats + if let Some(Value::INT(heartrate)) = activity_update.values.get(&4) { // 4 ID heartRate + channel_tx.send(*heartrate as u8).unwrap(); + } + } + } + } + 0 + } + + async fn handle_watch_nonce(&mut self, notification_value: &Vec) -> Result, Box> { + let watch_nonce: Vec = notification_value[15..31].to_vec(); + let watch_hmac: Vec = notification_value[33..65].to_vec(); + + let step2hmac = self.compute_auth_step3_hmac(watch_nonce.clone()).await.unwrap(); + + self.decryption_key = step2hmac[0..16].to_vec(); + self.encryption_key = step2hmac[16..32].to_vec(); + self.decryption_nonce = step2hmac[32..36].to_vec(); + self.decryption_nonce.append(&mut vec![0x00;8]); + + let encryption_nonce: &[u8] = &step2hmac[36..40]; + + + let mut mac = ::new_from_slice(&self.decryption_key) + .expect("HMAC can take key of any size"); + + let mut secret_key: Vec = vec![]; + secret_key.append(&mut watch_nonce.clone()); + secret_key.append(&mut self.nonce.clone()); + + mac.update(&secret_key.as_slice()); + let tmp = mac.finalize().into_bytes(); + let result = tmp.as_slice(); + + if result != watch_hmac { + return Err("Watch hmac mismatch")?; + } + + let mut next_packet: Vec = vec![0x00, 0x00, 0x02, 0x02, 0x08, 0x01, 0x10, 0x1b, 0x1a, 0x42, 0x82, 0x02, 0x3f, 0x0a, 0x20, 0xf2, 0x10, 0xa9, 0xc9, 0xb4, 0x2f, 0x35, 0x28, 0x7d, 0xa0, 0x29, 0x28, 0x41, 0xad, 0x79, 0x50, 0x06, 0x4e, 0x2b, 0x2d, 0x11, 0x6f, 0x0f, 0x1b, 0x59, 0x11, 0xa7, 0x93, 0x21, 0xed, 0x0a, 0xf9, 0x12, 0x1b, 0x8d, 0xfd, 0xb9, 0x42, 0x24, 0xf2, 0xc2, 0xff, 0x09, 0xdd, 0x12, 0x71, 0xb0, 0x9d, 0xc7, 0x36, 0x3c, 0xa6, 0x43, 0xd1, 0xaf, 0x20, 0xd6, 0x47, 0x04, 0x54, 0x9c]; + + let mut mac = ::new_from_slice(self.encryption_key.as_slice()) + .expect("HMAC can take key of any size"); + let mut secret_key: Vec = vec![]; + + secret_key.append(&mut self.nonce.clone()); + secret_key.append(&mut watch_nonce.clone()); + + mac.update(secret_key.as_slice()); + + let hmac_key = mac.finalize().into_bytes(); + let hmac_key_bytes = hmac_key.as_slice(); + + for (i,byte) in hmac_key_bytes.iter().enumerate() { + next_packet[i+15] = *byte; + } + + let device_info: Vec = vec![0x08, 0x00, 0x15, 0x00, 0x00, 0x04, 0x42, 0x1a, 0x07, 0x52, 0x4d, 0x58, 0x33, 0x33, 0x37, 0x30, 0x20, 0xe0, 0x01, 0x2a, 0x02, 0x45, 0x4e]; + + self.encryption_nonce = encryption_nonce.to_vec(); + let encrypted_device_info = self.encrypt(self.encryption_key.clone(), &mut self.encryption_nonce.clone(), device_info, 0); + + for (i,byte) in encrypted_device_info.iter().enumerate() { + next_packet[i+49] = *byte; + } + + Ok(next_packet) + } + + pub async fn compute_auth_step3_hmac(&mut self, watch_nonce: Vec) -> Result<[u8;64], Box> { + + let mut secret_key: Vec = vec![]; + secret_key.append(&mut self.nonce.clone()); + secret_key.append(&mut watch_nonce.clone()); + let mut mac = ::new_from_slice(secret_key.as_slice()) + .expect("HMAC can take key of any size"); + mac.update(hex::decode(self.auth_key.clone()).unwrap().as_slice()); + + let hmac_key = mac.finalize().into_bytes(); + let hmac_key_bytes = hmac_key.as_slice(); + + let mut output: [u8;64] = [0;64]; + let mut tmp: &[u8] = &[0;0]; + let mut b: u8 = 1; + let mut i = 0; + + + let mut tmp2; + while i < output.len(){ + mac = ::new_from_slice(hmac_key_bytes) + .expect("HMAC can take key of any size"); + let mut a: Vec = vec![]; + + a.append(&mut tmp.to_vec()); + a.append(&mut "miwear-auth".as_bytes().to_vec()); + a.append(&mut vec![b]); + mac.update(a.as_slice()); + tmp2 = mac.finalize().into_bytes(); + tmp = tmp2.as_slice(); + for j in tmp { + output[i] = *j; + i += 1; + } + b += 1; + } + Ok(output) + } + + pub fn encrypt(&mut self, key: Vec, nonce: &mut Vec, payload: Vec, i: u8) -> Vec { + nonce.append(&mut vec![0x00,0x00,0x00,0x00,i,0x00,0x00,0x00]); + let cipher = Aes128Ccm::new(GenericArray::from_slice(&key.as_slice())); + let nonce = GenericArray::from_slice(&nonce); // 12-bytes; unique per message + let ciphertext = cipher.encrypt(nonce, payload.as_slice()).unwrap(); + ciphertext + } + + fn decrypt(&mut self, payload: Vec) -> Vec { + let cipher = Aes128Ccm::new(GenericArray::from_slice(self.decryption_key.as_slice())); + let nonce = GenericArray::from_slice(&self.decryption_nonce); // 12-bytes; unique per message + let ciphertext = cipher.encrypt(nonce, payload.as_slice()).unwrap(); + ciphertext + } +} diff --git a/src/protobuf_decoder.rs b/src/protobuf_decoder.rs new file mode 100644 index 0000000..8cf75cb --- /dev/null +++ b/src/protobuf_decoder.rs @@ -0,0 +1,112 @@ +use core::str; +use std::collections::HashMap; + +#[derive(Debug)] +enum WireType { + VARINT = 1, + I64 = 2, + LEN = 3, + SGROUP = 4, + EGROUP = 5, + I32 = 6, + UNKNOWN = 7 +} + +impl From for WireType { + fn from(orig: u8) -> Self { + match orig { + 1 => WireType::VARINT, + 2 => WireType::I64, + 3 => WireType::LEN, + 4 => WireType::SGROUP, + 5 => WireType::EGROUP, + 6 => WireType::I32, + _ => WireType::UNKNOWN + } + } +} + +#[allow(dead_code)] +#[derive(Debug, Clone)] +pub enum Value { + INT(u16), + STRING(String), + PROTOBUF(Protobuf) +} + +#[derive(Debug, Clone)] +pub struct Protobuf { + pub values: HashMap +} + +pub struct Decoder {} + +impl Decoder { + pub fn decode(input: &Vec) -> Protobuf { + let mut hashmap: HashMap = HashMap::new(); + // println!("Huja: {:02x?}", input); + + if input.len() < 1 { + // Empty message + return Protobuf { values: hashmap }; + } + + let variant_key = input[0] & 0b01111111; + let field_number = variant_key >> 3; + let mut iter = input[2..].iter(); + + // Citing the documentation: "You now know that the first number in the stream is always a varint key" + if (input[1] >> 7) == 1 { + let a: u16 = input[1] as u16; + let b: u16 = *iter.next().unwrap() as u16; + hashmap.insert(field_number, Value::INT(((b & 0b01111111) << 7) | (a & 0b01111111))); + }else { + hashmap.insert(field_number, Value::INT(input[1] as u16)); + } + + while let Some(mut value) = iter.next() { + let variant_key = value & 0b01111111; + let wire_type: WireType = WireType::from((variant_key & 0b111) + 1); + let field_number = variant_key >> 3; + + // print!("{}:{:?}", field_number, wire_type); + + value = iter.next().unwrap(); + match wire_type { + WireType::VARINT => { + if (value >> 7) == 1 { + // print!( " e"); + let a: &u16 = &(*value as u16); + let b: &u16 = &(*iter.next().unwrap() as u16); + // println!(" value: {}", ((b & 0b01111111) << 7) | (a & 0b01111111)); + hashmap.insert(field_number, Value::INT(((b & 0b01111111) << 7) | (a & 0b01111111))); + }else { + // println!(" value: {}", value); + hashmap.insert(field_number, Value::INT(*value as u16)); + } + }, + WireType::LEN => { + let tmp = iter.clone().take(*value as usize).map(|x| *x).collect::>(); + if *value == 0 { + break; + } + iter.nth(*value as usize - 1 ); + let huj = str::from_utf8(tmp.as_slice()); + if huj.is_err() { + hashmap.insert(field_number,Value::PROTOBUF(Self::decode(&tmp[1..].to_vec()))); + }else { + hashmap.insert(field_number,Value::STRING(huj.unwrap().to_string())); + } + }, + WireType::UNKNOWN => { + // println!(" unknown skipping"); + break; + } + _ => { + // println!(" unimplemented: {:?}", wire_type); + } + } + } + Protobuf { values: hashmap } + } +} \ No newline at end of file diff --git a/src/xiaomi.rs b/src/xiaomi.rs new file mode 100644 index 0000000..39f697a --- /dev/null +++ b/src/xiaomi.rs @@ -0,0 +1,29681 @@ +// This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit +// .proto file is parsed by protoc --rs_out=... +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `xiaomi.proto` + +// @@protoc_insertion_point(message:xiaomi.Command) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct Command { + // message fields + // @@protoc_insertion_point(field:xiaomi.Command.type) + pub type_: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.Command.subtype) + pub subtype: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.Command.auth) + pub auth: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.system) + pub system: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.watchface) + pub watchface: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.health) + pub health: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.calendar) + pub calendar: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.music) + pub music: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.notification) + pub notification: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.weather) + pub weather: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.schedule) + pub schedule: ::protobuf::MessageField, + /// command type 21 + // @@protoc_insertion_point(field:xiaomi.Command.phonebook) + pub phonebook: ::protobuf::MessageField, + /// type 22 + // @@protoc_insertion_point(field:xiaomi.Command.dataUpload) + pub dataUpload: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Command.status) + pub status: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.Command.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Command { + fn default() -> &'a Command { + ::default_instance() + } +} + +impl Command { + pub fn new() -> Command { + ::std::default::Default::default() + } + + // required uint32 type = 1; + + pub fn type_(&self) -> u32 { + self.type_.unwrap_or(0) + } + + pub fn clear_type_(&mut self) { + self.type_ = ::std::option::Option::None; + } + + pub fn has_type(&self) -> bool { + self.type_.is_some() + } + + // Param is passed by value, moved + pub fn set_type(&mut self, v: u32) { + self.type_ = ::std::option::Option::Some(v); + } + + // optional uint32 subtype = 2; + + pub fn subtype(&self) -> u32 { + self.subtype.unwrap_or(0) + } + + pub fn clear_subtype(&mut self) { + self.subtype = ::std::option::Option::None; + } + + pub fn has_subtype(&self) -> bool { + self.subtype.is_some() + } + + // Param is passed by value, moved + pub fn set_subtype(&mut self, v: u32) { + self.subtype = ::std::option::Option::Some(v); + } + + // optional uint32 status = 100; + + pub fn status(&self) -> u32 { + self.status.unwrap_or(0) + } + + pub fn clear_status(&mut self) { + self.status = ::std::option::Option::None; + } + + pub fn has_status(&self) -> bool { + self.status.is_some() + } + + // Param is passed by value, moved + pub fn set_status(&mut self, v: u32) { + self.status = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(14); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "type", + |m: &Command| { &m.type_ }, + |m: &mut Command| { &mut m.type_ }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "subtype", + |m: &Command| { &m.subtype }, + |m: &mut Command| { &mut m.subtype }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Auth>( + "auth", + |m: &Command| { &m.auth }, + |m: &mut Command| { &mut m.auth }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, System>( + "system", + |m: &Command| { &m.system }, + |m: &mut Command| { &mut m.system }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Watchface>( + "watchface", + |m: &Command| { &m.watchface }, + |m: &mut Command| { &mut m.watchface }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Health>( + "health", + |m: &Command| { &m.health }, + |m: &mut Command| { &mut m.health }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Calendar>( + "calendar", + |m: &Command| { &m.calendar }, + |m: &mut Command| { &mut m.calendar }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Music>( + "music", + |m: &Command| { &m.music }, + |m: &mut Command| { &mut m.music }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Notification>( + "notification", + |m: &Command| { &m.notification }, + |m: &mut Command| { &mut m.notification }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Weather>( + "weather", + |m: &Command| { &m.weather }, + |m: &mut Command| { &mut m.weather }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Schedule>( + "schedule", + |m: &Command| { &m.schedule }, + |m: &mut Command| { &mut m.schedule }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Phonebook>( + "phonebook", + |m: &Command| { &m.phonebook }, + |m: &mut Command| { &mut m.phonebook }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, DataUpload>( + "dataUpload", + |m: &Command| { &m.dataUpload }, + |m: &mut Command| { &mut m.dataUpload }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "status", + |m: &Command| { &m.status }, + |m: &mut Command| { &mut m.status }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Command", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Command { + const NAME: &'static str = "Command"; + + fn is_initialized(&self) -> bool { + if self.type_.is_none() { + return false; + } + for v in &self.auth { + if !v.is_initialized() { + return false; + } + }; + for v in &self.system { + if !v.is_initialized() { + return false; + } + }; + for v in &self.watchface { + if !v.is_initialized() { + return false; + } + }; + for v in &self.health { + if !v.is_initialized() { + return false; + } + }; + for v in &self.calendar { + if !v.is_initialized() { + return false; + } + }; + for v in &self.music { + if !v.is_initialized() { + return false; + } + }; + for v in &self.notification { + if !v.is_initialized() { + return false; + } + }; + for v in &self.weather { + if !v.is_initialized() { + return false; + } + }; + for v in &self.schedule { + if !v.is_initialized() { + return false; + } + }; + for v in &self.phonebook { + if !v.is_initialized() { + return false; + } + }; + for v in &self.dataUpload { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.type_ = ::std::option::Option::Some(is.read_uint32()?); + }, + 16 => { + self.subtype = ::std::option::Option::Some(is.read_uint32()?); + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.auth)?; + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.system)?; + }, + 50 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.watchface)?; + }, + 82 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.health)?; + }, + 114 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.calendar)?; + }, + 162 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.music)?; + }, + 74 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.notification)?; + }, + 98 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.weather)?; + }, + 154 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.schedule)?; + }, + 186 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.phonebook)?; + }, + 194 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.dataUpload)?; + }, + 800 => { + self.status = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.type_ { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.subtype { + my_size += ::protobuf::rt::uint32_size(2, v); + } + if let Some(v) = self.auth.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.system.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.watchface.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.health.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.calendar.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.music.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.notification.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.weather.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.schedule.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.phonebook.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.dataUpload.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.status { + my_size += ::protobuf::rt::uint32_size(100, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.type_ { + os.write_uint32(1, v)?; + } + if let Some(v) = self.subtype { + os.write_uint32(2, v)?; + } + if let Some(v) = self.auth.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + if let Some(v) = self.system.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.watchface.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(6, v, os)?; + } + if let Some(v) = self.health.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(10, v, os)?; + } + if let Some(v) = self.calendar.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(14, v, os)?; + } + if let Some(v) = self.music.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(20, v, os)?; + } + if let Some(v) = self.notification.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(9, v, os)?; + } + if let Some(v) = self.weather.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(12, v, os)?; + } + if let Some(v) = self.schedule.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(19, v, os)?; + } + if let Some(v) = self.phonebook.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(23, v, os)?; + } + if let Some(v) = self.dataUpload.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(24, v, os)?; + } + if let Some(v) = self.status { + os.write_uint32(100, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Command { + Command::new() + } + + fn clear(&mut self) { + self.type_ = ::std::option::Option::None; + self.subtype = ::std::option::Option::None; + self.auth.clear(); + self.system.clear(); + self.watchface.clear(); + self.health.clear(); + self.calendar.clear(); + self.music.clear(); + self.notification.clear(); + self.weather.clear(); + self.schedule.clear(); + self.phonebook.clear(); + self.dataUpload.clear(); + self.status = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static Command { + static instance: Command = Command { + type_: ::std::option::Option::None, + subtype: ::std::option::Option::None, + auth: ::protobuf::MessageField::none(), + system: ::protobuf::MessageField::none(), + watchface: ::protobuf::MessageField::none(), + health: ::protobuf::MessageField::none(), + calendar: ::protobuf::MessageField::none(), + music: ::protobuf::MessageField::none(), + notification: ::protobuf::MessageField::none(), + weather: ::protobuf::MessageField::none(), + schedule: ::protobuf::MessageField::none(), + phonebook: ::protobuf::MessageField::none(), + dataUpload: ::protobuf::MessageField::none(), + status: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Command { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Command").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Command { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Command { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.Auth) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct Auth { + // message fields + // @@protoc_insertion_point(field:xiaomi.Auth.userId) + pub userId: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:xiaomi.Auth.status) + pub status: ::std::option::Option, + /// 1, 26 + // @@protoc_insertion_point(field:xiaomi.Auth.phoneNonce) + pub phoneNonce: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Auth.watchNonce) + pub watchNonce: ::protobuf::MessageField, + /// 1, 27 + // @@protoc_insertion_point(field:xiaomi.Auth.authStep3) + pub authStep3: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Auth.authStep4) + pub authStep4: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.Auth.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Auth { + fn default() -> &'a Auth { + ::default_instance() + } +} + +impl Auth { + pub fn new() -> Auth { + ::std::default::Default::default() + } + + // optional string userId = 7; + + pub fn userId(&self) -> &str { + match self.userId.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_userId(&mut self) { + self.userId = ::std::option::Option::None; + } + + pub fn has_userId(&self) -> bool { + self.userId.is_some() + } + + // Param is passed by value, moved + pub fn set_userId(&mut self, v: ::std::string::String) { + self.userId = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_userId(&mut self) -> &mut ::std::string::String { + if self.userId.is_none() { + self.userId = ::std::option::Option::Some(::std::string::String::new()); + } + self.userId.as_mut().unwrap() + } + + // Take field + pub fn take_userId(&mut self) -> ::std::string::String { + self.userId.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional uint32 status = 8; + + pub fn status(&self) -> u32 { + self.status.unwrap_or(0) + } + + pub fn clear_status(&mut self) { + self.status = ::std::option::Option::None; + } + + pub fn has_status(&self) -> bool { + self.status.is_some() + } + + // Param is passed by value, moved + pub fn set_status(&mut self, v: u32) { + self.status = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(6); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "userId", + |m: &Auth| { &m.userId }, + |m: &mut Auth| { &mut m.userId }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "status", + |m: &Auth| { &m.status }, + |m: &mut Auth| { &mut m.status }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, PhoneNonce>( + "phoneNonce", + |m: &Auth| { &m.phoneNonce }, + |m: &mut Auth| { &mut m.phoneNonce }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, WatchNonce>( + "watchNonce", + |m: &Auth| { &m.watchNonce }, + |m: &mut Auth| { &mut m.watchNonce }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, AuthStep3>( + "authStep3", + |m: &Auth| { &m.authStep3 }, + |m: &mut Auth| { &mut m.authStep3 }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, AuthStep4>( + "authStep4", + |m: &Auth| { &m.authStep4 }, + |m: &mut Auth| { &mut m.authStep4 }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Auth", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Auth { + const NAME: &'static str = "Auth"; + + fn is_initialized(&self) -> bool { + for v in &self.phoneNonce { + if !v.is_initialized() { + return false; + } + }; + for v in &self.watchNonce { + if !v.is_initialized() { + return false; + } + }; + for v in &self.authStep3 { + if !v.is_initialized() { + return false; + } + }; + for v in &self.authStep4 { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 58 => { + self.userId = ::std::option::Option::Some(is.read_string()?); + }, + 64 => { + self.status = ::std::option::Option::Some(is.read_uint32()?); + }, + 242 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.phoneNonce)?; + }, + 250 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.watchNonce)?; + }, + 258 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.authStep3)?; + }, + 266 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.authStep4)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.userId.as_ref() { + my_size += ::protobuf::rt::string_size(7, &v); + } + if let Some(v) = self.status { + my_size += ::protobuf::rt::uint32_size(8, v); + } + if let Some(v) = self.phoneNonce.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.watchNonce.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.authStep3.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.authStep4.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.userId.as_ref() { + os.write_string(7, v)?; + } + if let Some(v) = self.status { + os.write_uint32(8, v)?; + } + if let Some(v) = self.phoneNonce.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(30, v, os)?; + } + if let Some(v) = self.watchNonce.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(31, v, os)?; + } + if let Some(v) = self.authStep3.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(32, v, os)?; + } + if let Some(v) = self.authStep4.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(33, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Auth { + Auth::new() + } + + fn clear(&mut self) { + self.userId = ::std::option::Option::None; + self.status = ::std::option::Option::None; + self.phoneNonce.clear(); + self.watchNonce.clear(); + self.authStep3.clear(); + self.authStep4.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Auth { + static instance: Auth = Auth { + userId: ::std::option::Option::None, + status: ::std::option::Option::None, + phoneNonce: ::protobuf::MessageField::none(), + watchNonce: ::protobuf::MessageField::none(), + authStep3: ::protobuf::MessageField::none(), + authStep4: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Auth { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Auth").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Auth { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Auth { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.PhoneNonce) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct PhoneNonce { + // message fields + // @@protoc_insertion_point(field:xiaomi.PhoneNonce.nonce) + pub nonce: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.PhoneNonce.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a PhoneNonce { + fn default() -> &'a PhoneNonce { + ::default_instance() + } +} + +impl PhoneNonce { + pub fn new() -> PhoneNonce { + ::std::default::Default::default() + } + + // required bytes nonce = 1; + + pub fn nonce(&self) -> &[u8] { + match self.nonce.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_nonce(&mut self) { + self.nonce = ::std::option::Option::None; + } + + pub fn has_nonce(&self) -> bool { + self.nonce.is_some() + } + + // Param is passed by value, moved + pub fn set_nonce(&mut self, v: ::std::vec::Vec) { + self.nonce = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_nonce(&mut self) -> &mut ::std::vec::Vec { + if self.nonce.is_none() { + self.nonce = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.nonce.as_mut().unwrap() + } + + // Take field + pub fn take_nonce(&mut self) -> ::std::vec::Vec { + self.nonce.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "nonce", + |m: &PhoneNonce| { &m.nonce }, + |m: &mut PhoneNonce| { &mut m.nonce }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "PhoneNonce", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for PhoneNonce { + const NAME: &'static str = "PhoneNonce"; + + fn is_initialized(&self) -> bool { + if self.nonce.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.nonce = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.nonce.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.nonce.as_ref() { + os.write_bytes(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> PhoneNonce { + PhoneNonce::new() + } + + fn clear(&mut self) { + self.nonce = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static PhoneNonce { + static instance: PhoneNonce = PhoneNonce { + nonce: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for PhoneNonce { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("PhoneNonce").unwrap()).clone() + } +} + +impl ::std::fmt::Display for PhoneNonce { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for PhoneNonce { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.WatchNonce) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct WatchNonce { + // message fields + // @@protoc_insertion_point(field:xiaomi.WatchNonce.nonce) + pub nonce: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:xiaomi.WatchNonce.hmac) + pub hmac: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.WatchNonce.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a WatchNonce { + fn default() -> &'a WatchNonce { + ::default_instance() + } +} + +impl WatchNonce { + pub fn new() -> WatchNonce { + ::std::default::Default::default() + } + + // required bytes nonce = 1; + + pub fn nonce(&self) -> &[u8] { + match self.nonce.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_nonce(&mut self) { + self.nonce = ::std::option::Option::None; + } + + pub fn has_nonce(&self) -> bool { + self.nonce.is_some() + } + + // Param is passed by value, moved + pub fn set_nonce(&mut self, v: ::std::vec::Vec) { + self.nonce = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_nonce(&mut self) -> &mut ::std::vec::Vec { + if self.nonce.is_none() { + self.nonce = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.nonce.as_mut().unwrap() + } + + // Take field + pub fn take_nonce(&mut self) -> ::std::vec::Vec { + self.nonce.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required bytes hmac = 2; + + pub fn hmac(&self) -> &[u8] { + match self.hmac.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_hmac(&mut self) { + self.hmac = ::std::option::Option::None; + } + + pub fn has_hmac(&self) -> bool { + self.hmac.is_some() + } + + // Param is passed by value, moved + pub fn set_hmac(&mut self, v: ::std::vec::Vec) { + self.hmac = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_hmac(&mut self) -> &mut ::std::vec::Vec { + if self.hmac.is_none() { + self.hmac = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.hmac.as_mut().unwrap() + } + + // Take field + pub fn take_hmac(&mut self) -> ::std::vec::Vec { + self.hmac.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "nonce", + |m: &WatchNonce| { &m.nonce }, + |m: &mut WatchNonce| { &mut m.nonce }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "hmac", + |m: &WatchNonce| { &m.hmac }, + |m: &mut WatchNonce| { &mut m.hmac }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "WatchNonce", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for WatchNonce { + const NAME: &'static str = "WatchNonce"; + + fn is_initialized(&self) -> bool { + if self.nonce.is_none() { + return false; + } + if self.hmac.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.nonce = ::std::option::Option::Some(is.read_bytes()?); + }, + 18 => { + self.hmac = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.nonce.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.hmac.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.nonce.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.hmac.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> WatchNonce { + WatchNonce::new() + } + + fn clear(&mut self) { + self.nonce = ::std::option::Option::None; + self.hmac = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static WatchNonce { + static instance: WatchNonce = WatchNonce { + nonce: ::std::option::Option::None, + hmac: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for WatchNonce { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("WatchNonce").unwrap()).clone() + } +} + +impl ::std::fmt::Display for WatchNonce { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WatchNonce { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.AuthStep3) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct AuthStep3 { + // message fields + // @@protoc_insertion_point(field:xiaomi.AuthStep3.encryptedNonces) + pub encryptedNonces: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:xiaomi.AuthStep3.encryptedDeviceInfo) + pub encryptedDeviceInfo: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.AuthStep3.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a AuthStep3 { + fn default() -> &'a AuthStep3 { + ::default_instance() + } +} + +impl AuthStep3 { + pub fn new() -> AuthStep3 { + ::std::default::Default::default() + } + + // required bytes encryptedNonces = 1; + + pub fn encryptedNonces(&self) -> &[u8] { + match self.encryptedNonces.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_encryptedNonces(&mut self) { + self.encryptedNonces = ::std::option::Option::None; + } + + pub fn has_encryptedNonces(&self) -> bool { + self.encryptedNonces.is_some() + } + + // Param is passed by value, moved + pub fn set_encryptedNonces(&mut self, v: ::std::vec::Vec) { + self.encryptedNonces = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_encryptedNonces(&mut self) -> &mut ::std::vec::Vec { + if self.encryptedNonces.is_none() { + self.encryptedNonces = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.encryptedNonces.as_mut().unwrap() + } + + // Take field + pub fn take_encryptedNonces(&mut self) -> ::std::vec::Vec { + self.encryptedNonces.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required bytes encryptedDeviceInfo = 2; + + pub fn encryptedDeviceInfo(&self) -> &[u8] { + match self.encryptedDeviceInfo.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_encryptedDeviceInfo(&mut self) { + self.encryptedDeviceInfo = ::std::option::Option::None; + } + + pub fn has_encryptedDeviceInfo(&self) -> bool { + self.encryptedDeviceInfo.is_some() + } + + // Param is passed by value, moved + pub fn set_encryptedDeviceInfo(&mut self, v: ::std::vec::Vec) { + self.encryptedDeviceInfo = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_encryptedDeviceInfo(&mut self) -> &mut ::std::vec::Vec { + if self.encryptedDeviceInfo.is_none() { + self.encryptedDeviceInfo = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.encryptedDeviceInfo.as_mut().unwrap() + } + + // Take field + pub fn take_encryptedDeviceInfo(&mut self) -> ::std::vec::Vec { + self.encryptedDeviceInfo.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "encryptedNonces", + |m: &AuthStep3| { &m.encryptedNonces }, + |m: &mut AuthStep3| { &mut m.encryptedNonces }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "encryptedDeviceInfo", + |m: &AuthStep3| { &m.encryptedDeviceInfo }, + |m: &mut AuthStep3| { &mut m.encryptedDeviceInfo }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "AuthStep3", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for AuthStep3 { + const NAME: &'static str = "AuthStep3"; + + fn is_initialized(&self) -> bool { + if self.encryptedNonces.is_none() { + return false; + } + if self.encryptedDeviceInfo.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.encryptedNonces = ::std::option::Option::Some(is.read_bytes()?); + }, + 18 => { + self.encryptedDeviceInfo = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.encryptedNonces.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.encryptedDeviceInfo.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.encryptedNonces.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.encryptedDeviceInfo.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> AuthStep3 { + AuthStep3::new() + } + + fn clear(&mut self) { + self.encryptedNonces = ::std::option::Option::None; + self.encryptedDeviceInfo = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static AuthStep3 { + static instance: AuthStep3 = AuthStep3 { + encryptedNonces: ::std::option::Option::None, + encryptedDeviceInfo: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for AuthStep3 { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("AuthStep3").unwrap()).clone() + } +} + +impl ::std::fmt::Display for AuthStep3 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for AuthStep3 { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.AuthStep4) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct AuthStep4 { + // message fields + // @@protoc_insertion_point(field:xiaomi.AuthStep4.unknown1) + pub unknown1: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.AuthStep4.unknown2) + pub unknown2: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.AuthStep4.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a AuthStep4 { + fn default() -> &'a AuthStep4 { + ::default_instance() + } +} + +impl AuthStep4 { + pub fn new() -> AuthStep4 { + ::std::default::Default::default() + } + + // required uint32 unknown1 = 1; + + pub fn unknown1(&self) -> u32 { + self.unknown1.unwrap_or(0) + } + + pub fn clear_unknown1(&mut self) { + self.unknown1 = ::std::option::Option::None; + } + + pub fn has_unknown1(&self) -> bool { + self.unknown1.is_some() + } + + // Param is passed by value, moved + pub fn set_unknown1(&mut self, v: u32) { + self.unknown1 = ::std::option::Option::Some(v); + } + + // optional uint32 unknown2 = 2; + + pub fn unknown2(&self) -> u32 { + self.unknown2.unwrap_or(0) + } + + pub fn clear_unknown2(&mut self) { + self.unknown2 = ::std::option::Option::None; + } + + pub fn has_unknown2(&self) -> bool { + self.unknown2.is_some() + } + + // Param is passed by value, moved + pub fn set_unknown2(&mut self, v: u32) { + self.unknown2 = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "unknown1", + |m: &AuthStep4| { &m.unknown1 }, + |m: &mut AuthStep4| { &mut m.unknown1 }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "unknown2", + |m: &AuthStep4| { &m.unknown2 }, + |m: &mut AuthStep4| { &mut m.unknown2 }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "AuthStep4", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for AuthStep4 { + const NAME: &'static str = "AuthStep4"; + + fn is_initialized(&self) -> bool { + if self.unknown1.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.unknown1 = ::std::option::Option::Some(is.read_uint32()?); + }, + 16 => { + self.unknown2 = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.unknown1 { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.unknown2 { + my_size += ::protobuf::rt::uint32_size(2, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.unknown1 { + os.write_uint32(1, v)?; + } + if let Some(v) = self.unknown2 { + os.write_uint32(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> AuthStep4 { + AuthStep4::new() + } + + fn clear(&mut self) { + self.unknown1 = ::std::option::Option::None; + self.unknown2 = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static AuthStep4 { + static instance: AuthStep4 = AuthStep4 { + unknown1: ::std::option::Option::None, + unknown2: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for AuthStep4 { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("AuthStep4").unwrap()).clone() + } +} + +impl ::std::fmt::Display for AuthStep4 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for AuthStep4 { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.AuthDeviceInfo) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct AuthDeviceInfo { + // message fields + // @@protoc_insertion_point(field:xiaomi.AuthDeviceInfo.unknown1) + pub unknown1: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.AuthDeviceInfo.phoneApiLevel) + pub phoneApiLevel: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.AuthDeviceInfo.phoneName) + pub phoneName: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:xiaomi.AuthDeviceInfo.unknown3) + pub unknown3: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.AuthDeviceInfo.region) + pub region: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.AuthDeviceInfo.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a AuthDeviceInfo { + fn default() -> &'a AuthDeviceInfo { + ::default_instance() + } +} + +impl AuthDeviceInfo { + pub fn new() -> AuthDeviceInfo { + ::std::default::Default::default() + } + + // required uint32 unknown1 = 1; + + pub fn unknown1(&self) -> u32 { + self.unknown1.unwrap_or(0) + } + + pub fn clear_unknown1(&mut self) { + self.unknown1 = ::std::option::Option::None; + } + + pub fn has_unknown1(&self) -> bool { + self.unknown1.is_some() + } + + // Param is passed by value, moved + pub fn set_unknown1(&mut self, v: u32) { + self.unknown1 = ::std::option::Option::Some(v); + } + + // required float phoneApiLevel = 2; + + pub fn phoneApiLevel(&self) -> f32 { + self.phoneApiLevel.unwrap_or(0.) + } + + pub fn clear_phoneApiLevel(&mut self) { + self.phoneApiLevel = ::std::option::Option::None; + } + + pub fn has_phoneApiLevel(&self) -> bool { + self.phoneApiLevel.is_some() + } + + // Param is passed by value, moved + pub fn set_phoneApiLevel(&mut self, v: f32) { + self.phoneApiLevel = ::std::option::Option::Some(v); + } + + // required string phoneName = 3; + + pub fn phoneName(&self) -> &str { + match self.phoneName.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_phoneName(&mut self) { + self.phoneName = ::std::option::Option::None; + } + + pub fn has_phoneName(&self) -> bool { + self.phoneName.is_some() + } + + // Param is passed by value, moved + pub fn set_phoneName(&mut self, v: ::std::string::String) { + self.phoneName = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_phoneName(&mut self) -> &mut ::std::string::String { + if self.phoneName.is_none() { + self.phoneName = ::std::option::Option::Some(::std::string::String::new()); + } + self.phoneName.as_mut().unwrap() + } + + // Take field + pub fn take_phoneName(&mut self) -> ::std::string::String { + self.phoneName.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required uint32 unknown3 = 4; + + pub fn unknown3(&self) -> u32 { + self.unknown3.unwrap_or(0) + } + + pub fn clear_unknown3(&mut self) { + self.unknown3 = ::std::option::Option::None; + } + + pub fn has_unknown3(&self) -> bool { + self.unknown3.is_some() + } + + // Param is passed by value, moved + pub fn set_unknown3(&mut self, v: u32) { + self.unknown3 = ::std::option::Option::Some(v); + } + + // required string region = 5; + + pub fn region(&self) -> &str { + match self.region.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_region(&mut self) { + self.region = ::std::option::Option::None; + } + + pub fn has_region(&self) -> bool { + self.region.is_some() + } + + // Param is passed by value, moved + pub fn set_region(&mut self, v: ::std::string::String) { + self.region = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_region(&mut self) -> &mut ::std::string::String { + if self.region.is_none() { + self.region = ::std::option::Option::Some(::std::string::String::new()); + } + self.region.as_mut().unwrap() + } + + // Take field + pub fn take_region(&mut self) -> ::std::string::String { + self.region.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(5); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "unknown1", + |m: &AuthDeviceInfo| { &m.unknown1 }, + |m: &mut AuthDeviceInfo| { &mut m.unknown1 }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "phoneApiLevel", + |m: &AuthDeviceInfo| { &m.phoneApiLevel }, + |m: &mut AuthDeviceInfo| { &mut m.phoneApiLevel }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "phoneName", + |m: &AuthDeviceInfo| { &m.phoneName }, + |m: &mut AuthDeviceInfo| { &mut m.phoneName }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "unknown3", + |m: &AuthDeviceInfo| { &m.unknown3 }, + |m: &mut AuthDeviceInfo| { &mut m.unknown3 }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "region", + |m: &AuthDeviceInfo| { &m.region }, + |m: &mut AuthDeviceInfo| { &mut m.region }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "AuthDeviceInfo", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for AuthDeviceInfo { + const NAME: &'static str = "AuthDeviceInfo"; + + fn is_initialized(&self) -> bool { + if self.unknown1.is_none() { + return false; + } + if self.phoneApiLevel.is_none() { + return false; + } + if self.phoneName.is_none() { + return false; + } + if self.unknown3.is_none() { + return false; + } + if self.region.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.unknown1 = ::std::option::Option::Some(is.read_uint32()?); + }, + 21 => { + self.phoneApiLevel = ::std::option::Option::Some(is.read_float()?); + }, + 26 => { + self.phoneName = ::std::option::Option::Some(is.read_string()?); + }, + 32 => { + self.unknown3 = ::std::option::Option::Some(is.read_uint32()?); + }, + 42 => { + self.region = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.unknown1 { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.phoneApiLevel { + my_size += 1 + 4; + } + if let Some(v) = self.phoneName.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.unknown3 { + my_size += ::protobuf::rt::uint32_size(4, v); + } + if let Some(v) = self.region.as_ref() { + my_size += ::protobuf::rt::string_size(5, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.unknown1 { + os.write_uint32(1, v)?; + } + if let Some(v) = self.phoneApiLevel { + os.write_float(2, v)?; + } + if let Some(v) = self.phoneName.as_ref() { + os.write_string(3, v)?; + } + if let Some(v) = self.unknown3 { + os.write_uint32(4, v)?; + } + if let Some(v) = self.region.as_ref() { + os.write_string(5, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> AuthDeviceInfo { + AuthDeviceInfo::new() + } + + fn clear(&mut self) { + self.unknown1 = ::std::option::Option::None; + self.phoneApiLevel = ::std::option::Option::None; + self.phoneName = ::std::option::Option::None; + self.unknown3 = ::std::option::Option::None; + self.region = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static AuthDeviceInfo { + static instance: AuthDeviceInfo = AuthDeviceInfo { + unknown1: ::std::option::Option::None, + phoneApiLevel: ::std::option::Option::None, + phoneName: ::std::option::Option::None, + unknown3: ::std::option::Option::None, + region: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for AuthDeviceInfo { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("AuthDeviceInfo").unwrap()).clone() + } +} + +impl ::std::fmt::Display for AuthDeviceInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for AuthDeviceInfo { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.System) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct System { + // message fields + /// 2, 1 + // @@protoc_insertion_point(field:xiaomi.System.power) + pub power: ::protobuf::MessageField, + /// 2, 2 + // @@protoc_insertion_point(field:xiaomi.System.deviceInfo) + pub deviceInfo: ::protobuf::MessageField, + /// 2, 3 + // @@protoc_insertion_point(field:xiaomi.System.clock) + pub clock: ::protobuf::MessageField, + /// 2, 18 + // @@protoc_insertion_point(field:xiaomi.System.findDevice) + pub findDevice: ::std::option::Option, + /// 2, 29 get | 2, 39 set + // @@protoc_insertion_point(field:xiaomi.System.displayItems) + pub displayItems: ::protobuf::MessageField, + /// 2, 34 + // @@protoc_insertion_point(field:xiaomi.System.dndStatus) + pub dndStatus: ::protobuf::MessageField, + /// 2, 39 + // @@protoc_insertion_point(field:xiaomi.System.workoutTypes) + pub workoutTypes: ::protobuf::MessageField, + /// 2, 5 + // @@protoc_insertion_point(field:xiaomi.System.firmwareInstallRequest) + pub firmwareInstallRequest: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.System.firmwareInstallResponse) + pub firmwareInstallResponse: ::protobuf::MessageField, + /// 2, 9 get | 2, 21 set + // @@protoc_insertion_point(field:xiaomi.System.password) + pub password: ::protobuf::MessageField, + /// 2, 7 get | 2, 8 set + // @@protoc_insertion_point(field:xiaomi.System.camera) + pub camera: ::protobuf::MessageField, + /// 2, 6 + // @@protoc_insertion_point(field:xiaomi.System.language) + pub language: ::protobuf::MessageField, + /// 2, 51 get | 2, 52 create + // @@protoc_insertion_point(field:xiaomi.System.widgetScreens) + pub widgetScreens: ::protobuf::MessageField, + /// 2, 53 + // @@protoc_insertion_point(field:xiaomi.System.widgetParts) + pub widgetParts: ::protobuf::MessageField, + /// 2, 14 + // @@protoc_insertion_point(field:xiaomi.System.miscSettingGet) + pub miscSettingGet: ::protobuf::MessageField, + /// 2, 15 + // @@protoc_insertion_point(field:xiaomi.System.miscSettingSet) + pub miscSettingSet: ::protobuf::MessageField, + /// 2, 43 + // @@protoc_insertion_point(field:xiaomi.System.phoneSilentModeGet) + pub phoneSilentModeGet: ::protobuf::MessageField, + /// 2, 44 returning to watch, 2, 45 setting from watch + // @@protoc_insertion_point(field:xiaomi.System.phoneSilentModeSet) + pub phoneSilentModeSet: ::protobuf::MessageField, + /// 2, 46 + // @@protoc_insertion_point(field:xiaomi.System.vibrationPatterns) + pub vibrationPatterns: ::protobuf::MessageField, + /// 2, 47 + // @@protoc_insertion_point(field:xiaomi.System.vibrationSetPreset) + pub vibrationSetPreset: ::protobuf::MessageField, + /// 2, 58 + // @@protoc_insertion_point(field:xiaomi.System.vibrationPatternCreate) + pub vibrationPatternCreate: ::protobuf::MessageField, + /// 2, 59 + // @@protoc_insertion_point(field:xiaomi.System.vibrationTestCustom) + pub vibrationTestCustom: ::protobuf::MessageField, + /// 2, 47 + // @@protoc_insertion_point(field:xiaomi.System.vibrationPatternAck) + pub vibrationPatternAck: ::protobuf::MessageField, + /// 2, 78 + // @@protoc_insertion_point(field:xiaomi.System.basicDeviceState) + pub basicDeviceState: ::protobuf::MessageField, + /// 2, 79 + // @@protoc_insertion_point(field:xiaomi.System.deviceState) + pub deviceState: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.System.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a System { + fn default() -> &'a System { + ::default_instance() + } +} + +impl System { + pub fn new() -> System { + ::std::default::Default::default() + } + + // optional uint32 findDevice = 5; + + pub fn findDevice(&self) -> u32 { + self.findDevice.unwrap_or(0) + } + + pub fn clear_findDevice(&mut self) { + self.findDevice = ::std::option::Option::None; + } + + pub fn has_findDevice(&self) -> bool { + self.findDevice.is_some() + } + + // Param is passed by value, moved + pub fn set_findDevice(&mut self, v: u32) { + self.findDevice = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(25); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Power>( + "power", + |m: &System| { &m.power }, + |m: &mut System| { &mut m.power }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, DeviceInfo>( + "deviceInfo", + |m: &System| { &m.deviceInfo }, + |m: &mut System| { &mut m.deviceInfo }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Clock>( + "clock", + |m: &System| { &m.clock }, + |m: &mut System| { &mut m.clock }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "findDevice", + |m: &System| { &m.findDevice }, + |m: &mut System| { &mut m.findDevice }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, DisplayItems>( + "displayItems", + |m: &System| { &m.displayItems }, + |m: &mut System| { &mut m.displayItems }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, DoNotDisturb>( + "dndStatus", + |m: &System| { &m.dndStatus }, + |m: &mut System| { &mut m.dndStatus }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, WorkoutTypes>( + "workoutTypes", + |m: &System| { &m.workoutTypes }, + |m: &mut System| { &mut m.workoutTypes }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, FirmwareInstallRequest>( + "firmwareInstallRequest", + |m: &System| { &m.firmwareInstallRequest }, + |m: &mut System| { &mut m.firmwareInstallRequest }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, FirmwareInstallResponse>( + "firmwareInstallResponse", + |m: &System| { &m.firmwareInstallResponse }, + |m: &mut System| { &mut m.firmwareInstallResponse }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Password>( + "password", + |m: &System| { &m.password }, + |m: &mut System| { &mut m.password }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Camera>( + "camera", + |m: &System| { &m.camera }, + |m: &mut System| { &mut m.camera }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Language>( + "language", + |m: &System| { &m.language }, + |m: &mut System| { &mut m.language }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, WidgetScreens>( + "widgetScreens", + |m: &System| { &m.widgetScreens }, + |m: &mut System| { &mut m.widgetScreens }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, WidgetParts>( + "widgetParts", + |m: &System| { &m.widgetParts }, + |m: &mut System| { &mut m.widgetParts }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MiscSettingGet>( + "miscSettingGet", + |m: &System| { &m.miscSettingGet }, + |m: &mut System| { &mut m.miscSettingGet }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MiscSettingSet>( + "miscSettingSet", + |m: &System| { &m.miscSettingSet }, + |m: &mut System| { &mut m.miscSettingSet }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, PhoneSilentModeGet>( + "phoneSilentModeGet", + |m: &System| { &m.phoneSilentModeGet }, + |m: &mut System| { &mut m.phoneSilentModeGet }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, PhoneSilentModeSet>( + "phoneSilentModeSet", + |m: &System| { &m.phoneSilentModeSet }, + |m: &mut System| { &mut m.phoneSilentModeSet }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, VibrationPatterns>( + "vibrationPatterns", + |m: &System| { &m.vibrationPatterns }, + |m: &mut System| { &mut m.vibrationPatterns }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, VibrationNotificationType>( + "vibrationSetPreset", + |m: &System| { &m.vibrationSetPreset }, + |m: &mut System| { &mut m.vibrationSetPreset }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, CustomVibrationPattern>( + "vibrationPatternCreate", + |m: &System| { &m.vibrationPatternCreate }, + |m: &mut System| { &mut m.vibrationPatternCreate }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, VibrationTest>( + "vibrationTestCustom", + |m: &System| { &m.vibrationTestCustom }, + |m: &mut System| { &mut m.vibrationTestCustom }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, VibrationPatternAck>( + "vibrationPatternAck", + |m: &System| { &m.vibrationPatternAck }, + |m: &mut System| { &mut m.vibrationPatternAck }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, BasicDeviceState>( + "basicDeviceState", + |m: &System| { &m.basicDeviceState }, + |m: &mut System| { &mut m.basicDeviceState }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, DeviceState>( + "deviceState", + |m: &System| { &m.deviceState }, + |m: &mut System| { &mut m.deviceState }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "System", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for System { + const NAME: &'static str = "System"; + + fn is_initialized(&self) -> bool { + for v in &self.power { + if !v.is_initialized() { + return false; + } + }; + for v in &self.deviceInfo { + if !v.is_initialized() { + return false; + } + }; + for v in &self.clock { + if !v.is_initialized() { + return false; + } + }; + for v in &self.displayItems { + if !v.is_initialized() { + return false; + } + }; + for v in &self.dndStatus { + if !v.is_initialized() { + return false; + } + }; + for v in &self.workoutTypes { + if !v.is_initialized() { + return false; + } + }; + for v in &self.firmwareInstallRequest { + if !v.is_initialized() { + return false; + } + }; + for v in &self.firmwareInstallResponse { + if !v.is_initialized() { + return false; + } + }; + for v in &self.password { + if !v.is_initialized() { + return false; + } + }; + for v in &self.camera { + if !v.is_initialized() { + return false; + } + }; + for v in &self.language { + if !v.is_initialized() { + return false; + } + }; + for v in &self.widgetScreens { + if !v.is_initialized() { + return false; + } + }; + for v in &self.widgetParts { + if !v.is_initialized() { + return false; + } + }; + for v in &self.miscSettingGet { + if !v.is_initialized() { + return false; + } + }; + for v in &self.miscSettingSet { + if !v.is_initialized() { + return false; + } + }; + for v in &self.phoneSilentModeGet { + if !v.is_initialized() { + return false; + } + }; + for v in &self.phoneSilentModeSet { + if !v.is_initialized() { + return false; + } + }; + for v in &self.vibrationPatterns { + if !v.is_initialized() { + return false; + } + }; + for v in &self.vibrationSetPreset { + if !v.is_initialized() { + return false; + } + }; + for v in &self.vibrationPatternCreate { + if !v.is_initialized() { + return false; + } + }; + for v in &self.vibrationTestCustom { + if !v.is_initialized() { + return false; + } + }; + for v in &self.vibrationPatternAck { + if !v.is_initialized() { + return false; + } + }; + for v in &self.basicDeviceState { + if !v.is_initialized() { + return false; + } + }; + for v in &self.deviceState { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.power)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.deviceInfo)?; + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.clock)?; + }, + 40 => { + self.findDevice = ::std::option::Option::Some(is.read_uint32()?); + }, + 82 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.displayItems)?; + }, + 90 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.dndStatus)?; + }, + 114 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.workoutTypes)?; + }, + 130 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.firmwareInstallRequest)?; + }, + 138 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.firmwareInstallResponse)?; + }, + 154 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.password)?; + }, + 122 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.camera)?; + }, + 162 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.language)?; + }, + 226 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.widgetScreens)?; + }, + 234 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.widgetParts)?; + }, + 274 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.miscSettingGet)?; + }, + 282 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.miscSettingSet)?; + }, + 290 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.phoneSilentModeGet)?; + }, + 298 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.phoneSilentModeSet)?; + }, + 306 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.vibrationPatterns)?; + }, + 314 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.vibrationSetPreset)?; + }, + 322 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.vibrationPatternCreate)?; + }, + 330 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.vibrationTestCustom)?; + }, + 346 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.vibrationPatternAck)?; + }, + 386 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.basicDeviceState)?; + }, + 394 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.deviceState)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.power.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.deviceInfo.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.clock.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.findDevice { + my_size += ::protobuf::rt::uint32_size(5, v); + } + if let Some(v) = self.displayItems.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.dndStatus.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.workoutTypes.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.firmwareInstallRequest.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.firmwareInstallResponse.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.password.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.camera.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.language.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.widgetScreens.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.widgetParts.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.miscSettingGet.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.miscSettingSet.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.phoneSilentModeGet.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.phoneSilentModeSet.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.vibrationPatterns.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.vibrationSetPreset.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.vibrationPatternCreate.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.vibrationTestCustom.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.vibrationPatternAck.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.basicDeviceState.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.deviceState.as_ref() { + let len = v.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.power.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.deviceInfo.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + if let Some(v) = self.clock.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.findDevice { + os.write_uint32(5, v)?; + } + if let Some(v) = self.displayItems.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(10, v, os)?; + } + if let Some(v) = self.dndStatus.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(11, v, os)?; + } + if let Some(v) = self.workoutTypes.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(14, v, os)?; + } + if let Some(v) = self.firmwareInstallRequest.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(16, v, os)?; + } + if let Some(v) = self.firmwareInstallResponse.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(17, v, os)?; + } + if let Some(v) = self.password.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(19, v, os)?; + } + if let Some(v) = self.camera.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(15, v, os)?; + } + if let Some(v) = self.language.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(20, v, os)?; + } + if let Some(v) = self.widgetScreens.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(28, v, os)?; + } + if let Some(v) = self.widgetParts.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(29, v, os)?; + } + if let Some(v) = self.miscSettingGet.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(34, v, os)?; + } + if let Some(v) = self.miscSettingSet.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(35, v, os)?; + } + if let Some(v) = self.phoneSilentModeGet.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(36, v, os)?; + } + if let Some(v) = self.phoneSilentModeSet.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(37, v, os)?; + } + if let Some(v) = self.vibrationPatterns.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(38, v, os)?; + } + if let Some(v) = self.vibrationSetPreset.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(39, v, os)?; + } + if let Some(v) = self.vibrationPatternCreate.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(40, v, os)?; + } + if let Some(v) = self.vibrationTestCustom.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(41, v, os)?; + } + if let Some(v) = self.vibrationPatternAck.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(43, v, os)?; + } + if let Some(v) = self.basicDeviceState.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(48, v, os)?; + } + if let Some(v) = self.deviceState.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(49, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> System { + System::new() + } + + fn clear(&mut self) { + self.power.clear(); + self.deviceInfo.clear(); + self.clock.clear(); + self.findDevice = ::std::option::Option::None; + self.displayItems.clear(); + self.dndStatus.clear(); + self.workoutTypes.clear(); + self.firmwareInstallRequest.clear(); + self.firmwareInstallResponse.clear(); + self.password.clear(); + self.camera.clear(); + self.language.clear(); + self.widgetScreens.clear(); + self.widgetParts.clear(); + self.miscSettingGet.clear(); + self.miscSettingSet.clear(); + self.phoneSilentModeGet.clear(); + self.phoneSilentModeSet.clear(); + self.vibrationPatterns.clear(); + self.vibrationSetPreset.clear(); + self.vibrationPatternCreate.clear(); + self.vibrationTestCustom.clear(); + self.vibrationPatternAck.clear(); + self.basicDeviceState.clear(); + self.deviceState.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static System { + static instance: System = System { + power: ::protobuf::MessageField::none(), + deviceInfo: ::protobuf::MessageField::none(), + clock: ::protobuf::MessageField::none(), + findDevice: ::std::option::Option::None, + displayItems: ::protobuf::MessageField::none(), + dndStatus: ::protobuf::MessageField::none(), + workoutTypes: ::protobuf::MessageField::none(), + firmwareInstallRequest: ::protobuf::MessageField::none(), + firmwareInstallResponse: ::protobuf::MessageField::none(), + password: ::protobuf::MessageField::none(), + camera: ::protobuf::MessageField::none(), + language: ::protobuf::MessageField::none(), + widgetScreens: ::protobuf::MessageField::none(), + widgetParts: ::protobuf::MessageField::none(), + miscSettingGet: ::protobuf::MessageField::none(), + miscSettingSet: ::protobuf::MessageField::none(), + phoneSilentModeGet: ::protobuf::MessageField::none(), + phoneSilentModeSet: ::protobuf::MessageField::none(), + vibrationPatterns: ::protobuf::MessageField::none(), + vibrationSetPreset: ::protobuf::MessageField::none(), + vibrationPatternCreate: ::protobuf::MessageField::none(), + vibrationTestCustom: ::protobuf::MessageField::none(), + vibrationPatternAck: ::protobuf::MessageField::none(), + basicDeviceState: ::protobuf::MessageField::none(), + deviceState: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for System { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("System").unwrap()).clone() + } +} + +impl ::std::fmt::Display for System { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for System { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.Power) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct Power { + // message fields + // @@protoc_insertion_point(field:xiaomi.Power.battery) + pub battery: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.Power.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Power { + fn default() -> &'a Power { + ::default_instance() + } +} + +impl Power { + pub fn new() -> Power { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Battery>( + "battery", + |m: &Power| { &m.battery }, + |m: &mut Power| { &mut m.battery }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Power", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Power { + const NAME: &'static str = "Power"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.battery)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.battery.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.battery.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Power { + Power::new() + } + + fn clear(&mut self) { + self.battery.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Power { + static instance: Power = Power { + battery: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Power { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Power").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Power { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Power { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.Battery) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct Battery { + // message fields + // @@protoc_insertion_point(field:xiaomi.Battery.level) + pub level: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.Battery.state) + pub state: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.Battery.lastCharge) + pub lastCharge: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.Battery.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Battery { + fn default() -> &'a Battery { + ::default_instance() + } +} + +impl Battery { + pub fn new() -> Battery { + ::std::default::Default::default() + } + + // optional uint32 level = 1; + + pub fn level(&self) -> u32 { + self.level.unwrap_or(0) + } + + pub fn clear_level(&mut self) { + self.level = ::std::option::Option::None; + } + + pub fn has_level(&self) -> bool { + self.level.is_some() + } + + // Param is passed by value, moved + pub fn set_level(&mut self, v: u32) { + self.level = ::std::option::Option::Some(v); + } + + // optional uint32 state = 2; + + pub fn state(&self) -> u32 { + self.state.unwrap_or(0) + } + + pub fn clear_state(&mut self) { + self.state = ::std::option::Option::None; + } + + pub fn has_state(&self) -> bool { + self.state.is_some() + } + + // Param is passed by value, moved + pub fn set_state(&mut self, v: u32) { + self.state = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "level", + |m: &Battery| { &m.level }, + |m: &mut Battery| { &mut m.level }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "state", + |m: &Battery| { &m.state }, + |m: &mut Battery| { &mut m.state }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, LastCharge>( + "lastCharge", + |m: &Battery| { &m.lastCharge }, + |m: &mut Battery| { &mut m.lastCharge }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Battery", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Battery { + const NAME: &'static str = "Battery"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.level = ::std::option::Option::Some(is.read_uint32()?); + }, + 16 => { + self.state = ::std::option::Option::Some(is.read_uint32()?); + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.lastCharge)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.level { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.state { + my_size += ::protobuf::rt::uint32_size(2, v); + } + if let Some(v) = self.lastCharge.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.level { + os.write_uint32(1, v)?; + } + if let Some(v) = self.state { + os.write_uint32(2, v)?; + } + if let Some(v) = self.lastCharge.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Battery { + Battery::new() + } + + fn clear(&mut self) { + self.level = ::std::option::Option::None; + self.state = ::std::option::Option::None; + self.lastCharge.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Battery { + static instance: Battery = Battery { + level: ::std::option::Option::None, + state: ::std::option::Option::None, + lastCharge: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Battery { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Battery").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Battery { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Battery { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.LastCharge) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct LastCharge { + // message fields + // @@protoc_insertion_point(field:xiaomi.LastCharge.state) + pub state: ::std::option::Option, + // @@protoc_insertion_point(field:xiaomi.LastCharge.timestampSeconds) + pub timestampSeconds: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.LastCharge.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a LastCharge { + fn default() -> &'a LastCharge { + ::default_instance() + } +} + +impl LastCharge { + pub fn new() -> LastCharge { + ::std::default::Default::default() + } + + // optional uint32 state = 1; + + pub fn state(&self) -> u32 { + self.state.unwrap_or(0) + } + + pub fn clear_state(&mut self) { + self.state = ::std::option::Option::None; + } + + pub fn has_state(&self) -> bool { + self.state.is_some() + } + + // Param is passed by value, moved + pub fn set_state(&mut self, v: u32) { + self.state = ::std::option::Option::Some(v); + } + + // optional uint32 timestampSeconds = 2; + + pub fn timestampSeconds(&self) -> u32 { + self.timestampSeconds.unwrap_or(0) + } + + pub fn clear_timestampSeconds(&mut self) { + self.timestampSeconds = ::std::option::Option::None; + } + + pub fn has_timestampSeconds(&self) -> bool { + self.timestampSeconds.is_some() + } + + // Param is passed by value, moved + pub fn set_timestampSeconds(&mut self, v: u32) { + self.timestampSeconds = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "state", + |m: &LastCharge| { &m.state }, + |m: &mut LastCharge| { &mut m.state }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "timestampSeconds", + |m: &LastCharge| { &m.timestampSeconds }, + |m: &mut LastCharge| { &mut m.timestampSeconds }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "LastCharge", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for LastCharge { + const NAME: &'static str = "LastCharge"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.state = ::std::option::Option::Some(is.read_uint32()?); + }, + 16 => { + self.timestampSeconds = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.state { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.timestampSeconds { + my_size += ::protobuf::rt::uint32_size(2, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.state { + os.write_uint32(1, v)?; + } + if let Some(v) = self.timestampSeconds { + os.write_uint32(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> LastCharge { + LastCharge::new() + } + + fn clear(&mut self) { + self.state = ::std::option::Option::None; + self.timestampSeconds = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static LastCharge { + static instance: LastCharge = LastCharge { + state: ::std::option::Option::None, + timestampSeconds: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for LastCharge { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("LastCharge").unwrap()).clone() + } +} + +impl ::std::fmt::Display for LastCharge { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for LastCharge { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.DeviceInfo) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct DeviceInfo { + // message fields + // @@protoc_insertion_point(field:xiaomi.DeviceInfo.serialNumber) + pub serialNumber: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:xiaomi.DeviceInfo.firmware) + pub firmware: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:xiaomi.DeviceInfo.unknown3) + pub unknown3: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:xiaomi.DeviceInfo.model) + pub model: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:xiaomi.DeviceInfo.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a DeviceInfo { + fn default() -> &'a DeviceInfo { + ::default_instance() + } +} + +impl DeviceInfo { + pub fn new() -> DeviceInfo { + ::std::default::Default::default() + } + + // required string serialNumber = 1; + + pub fn serialNumber(&self) -> &str { + match self.serialNumber.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_serialNumber(&mut self) { + self.serialNumber = ::std::option::Option::None; + } + + pub fn has_serialNumber(&self) -> bool { + self.serialNumber.is_some() + } + + // Param is passed by value, moved + pub fn set_serialNumber(&mut self, v: ::std::string::String) { + self.serialNumber = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_serialNumber(&mut self) -> &mut ::std::string::String { + if self.serialNumber.is_none() { + self.serialNumber = ::std::option::Option::Some(::std::string::String::new()); + } + self.serialNumber.as_mut().unwrap() + } + + // Take field + pub fn take_serialNumber(&mut self) -> ::std::string::String { + self.serialNumber.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string firmware = 2; + + pub fn firmware(&self) -> &str { + match self.firmware.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_firmware(&mut self) { + self.firmware = ::std::option::Option::None; + } + + pub fn has_firmware(&self) -> bool { + self.firmware.is_some() + } + + // Param is passed by value, moved + pub fn set_firmware(&mut self, v: ::std::string::String) { + self.firmware = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_firmware(&mut self) -> &mut ::std::string::String { + if self.firmware.is_none() { + self.firmware = ::std::option::Option::Some(::std::string::String::new()); + } + self.firmware.as_mut().unwrap() + } + + // Take field + pub fn take_firmware(&mut self) -> ::std::string::String { + self.firmware.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string unknown3 = 3; + + pub fn unknown3(&self) -> &str { + match self.unknown3.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_unknown3(&mut self) { + self.unknown3 = ::std::option::Option::None; + } + + pub fn has_unknown3(&self) -> bool { + self.unknown3.is_some() + } + + // Param is passed by value, moved + pub fn set_unknown3(&mut self, v: ::std::string::String) { + self.unknown3 = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_unknown3(&mut self) -> &mut ::std::string::String { + if self.unknown3.is_none() { + self.unknown3 = ::std::option::Option::Some(::std::string::String::new()); + } + self.unknown3.as_mut().unwrap() + } + + // Take field + pub fn take_unknown3(&mut self) -> ::std::string::String { + self.unknown3.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string model = 4; + + pub fn model(&self) -> &str { + match self.model.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_model(&mut self) { + self.model = ::std::option::Option::None; + } + + pub fn has_model(&self) -> bool { + self.model.is_some() + } + + // Param is passed by value, moved + pub fn set_model(&mut self, v: ::std::string::String) { + self.model = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_model(&mut self) -> &mut ::std::string::String { + if self.model.is_none() { + self.model = ::std::option::Option::Some(::std::string::String::new()); + } + self.model.as_mut().unwrap() + } + + // Take field + pub fn take_model(&mut self) -> ::std::string::String { + self.model.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "serialNumber", + |m: &DeviceInfo| { &m.serialNumber }, + |m: &mut DeviceInfo| { &mut m.serialNumber }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "firmware", + |m: &DeviceInfo| { &m.firmware }, + |m: &mut DeviceInfo| { &mut m.firmware }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "unknown3", + |m: &DeviceInfo| { &m.unknown3 }, + |m: &mut DeviceInfo| { &mut m.unknown3 }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "model", + |m: &DeviceInfo| { &m.model }, + |m: &mut DeviceInfo| { &mut m.model }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "DeviceInfo", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for DeviceInfo { + const NAME: &'static str = "DeviceInfo"; + + fn is_initialized(&self) -> bool { + if self.serialNumber.is_none() { + return false; + } + if self.firmware.is_none() { + return false; + } + if self.model.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.serialNumber = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.firmware = ::std::option::Option::Some(is.read_string()?); + }, + 26 => { + self.unknown3 = ::std::option::Option::Some(is.read_string()?); + }, + 34 => { + self.model = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.serialNumber.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.firmware.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(v) = self.unknown3.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.model.as_ref() { + my_size += ::protobuf::rt::string_size(4, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.serialNumber.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.firmware.as_ref() { + os.write_string(2, v)?; + } + if let Some(v) = self.unknown3.as_ref() { + os.write_string(3, v)?; + } + if let Some(v) = self.model.as_ref() { + os.write_string(4, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> DeviceInfo { + DeviceInfo::new() + } + + fn clear(&mut self) { + self.serialNumber = ::std::option::Option::None; + self.firmware = ::std::option::Option::None; + self.unknown3 = ::std::option::Option::None; + self.model = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static DeviceInfo { + static instance: DeviceInfo = DeviceInfo { + serialNumber: ::std::option::Option::None, + firmware: ::std::option::Option::None, + unknown3: ::std::option::Option::None, + model: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for DeviceInfo { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("DeviceInfo").unwrap()).clone() + } +} + +impl ::std::fmt::Display for DeviceInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for DeviceInfo { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:xiaomi.Clock) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct Clock { + // message fields + // @@protoc_insertion_point(field:xiaomi.Clock.date) + pub date: ::protobuf::MessageField, + // @@protoc_insertion_point(field:xiaomi.Clock.time) + pub time: ::protobuf::MessageField