From a007e062ab5f57acd9f75c7645f0ac82652715c3 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 8 Sep 2021 13:52:52 +0200 Subject: [PATCH] style(core): apply rustfmt [no changelog] --- core/embed/rust/src/protobuf/defs.rs | 8 +++++--- core/embed/rust/src/protobuf/encode.rs | 2 +- core/embed/rust/src/protobuf/obj.rs | 23 ++++++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/core/embed/rust/src/protobuf/defs.rs b/core/embed/rust/src/protobuf/defs.rs index f66dc6e2a..5d07789c8 100644 --- a/core/embed/rust/src/protobuf/defs.rs +++ b/core/embed/rust/src/protobuf/defs.rs @@ -1,5 +1,5 @@ -use core::{mem, slice}; use crate::error::Error; +use core::{mem, slice}; pub struct MsgDef { pub fields: &'static [FieldDef], @@ -112,7 +112,8 @@ struct NameDef { static ENUM_DEFS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/../../../../proto_enums.data")); static MSG_DEFS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/../../../..//proto_msgs.data")); -static NAME_DEFS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/../../../..//proto_names.data")); +static NAME_DEFS: &[u8] = + include_bytes!(concat!(env!("OUT_DIR"), "/../../../..//proto_names.data")); static WIRE_DEFS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/../../../..//proto_wire.data")); pub fn find_name_by_msg_offset(msg_offset: u16) -> Result { @@ -123,7 +124,8 @@ pub fn find_name_by_msg_offset(msg_offset: u16) -> Result { ) }; - name_defs.iter() + name_defs + .iter() .filter(|def| def.msg_offset == msg_offset) .next() .map(|def| def.msg_name) diff --git a/core/embed/rust/src/protobuf/encode.rs b/core/embed/rust/src/protobuf/encode.rs index ca79b2c93..4cf0112fd 100644 --- a/core/embed/rust/src/protobuf/encode.rs +++ b/core/embed/rust/src/protobuf/encode.rs @@ -15,7 +15,7 @@ use crate::{ use super::{ defs::{FieldDef, FieldType, MsgDef}, - obj::{MsgObj}, + obj::MsgObj, zigzag, }; diff --git a/core/embed/rust/src/protobuf/obj.rs b/core/embed/rust/src/protobuf/obj.rs index e51a03313..bfd6544d6 100644 --- a/core/embed/rust/src/protobuf/obj.rs +++ b/core/embed/rust/src/protobuf/obj.rs @@ -67,7 +67,9 @@ impl MsgObj { match attr { Qstr::MP_QSTR_MESSAGE_WIRE_TYPE => { // Return the wire ID of this message def, or None if not set. - Ok(self.msg_wire_id.map_or(Obj::const_none(), |wire_id| wire_id.into())) + Ok(self + .msg_wire_id + .map_or(Obj::const_none(), |wire_id| wire_id.into())) } Qstr::MP_QSTR_MESSAGE_NAME => { // Return the qstr name of this message def @@ -79,7 +81,7 @@ impl MsgObj { // we're returning a mutable dict. Ok(Gc::new(Dict::with_map(self.map.clone())).into()) } - _ => { Err(Error::Missing) } + _ => Err(Error::Missing), } } @@ -198,7 +200,7 @@ impl TryFrom for Gc { unsafe extern "C" fn msg_def_obj_attr(self_in: Obj, attr: ffi::qstr, dest: *mut Obj) { util::try_or_raise(|| { - let this= Gc::::try_from(self_in)?; + let this = Gc::::try_from(self_in)?; let attr = Qstr::from_u16(attr as _); if unsafe { dest.read() } != Obj::const_null() { @@ -209,7 +211,9 @@ unsafe extern "C" fn msg_def_obj_attr(self_in: Obj, attr: ffi::qstr, dest: *mut Qstr::MP_QSTR_MESSAGE_NAME => { // Return the qstr name of this message def let name = Qstr::from_u16(find_name_by_msg_offset(this.def.offset)?); - unsafe { dest.write(name.into()); }; + unsafe { + dest.write(name.into()); + }; } Qstr::MP_QSTR_MESSAGE_WIRE_TYPE => { // Return the wire type of this message def @@ -217,7 +221,9 @@ unsafe extern "C" fn msg_def_obj_attr(self_in: Obj, attr: ffi::qstr, dest: *mut .def .wire_id .map_or_else(Obj::const_none, |wire_id| wire_id.into()); - unsafe { dest.write(wire_id_obj); }; + unsafe { + dest.write(wire_id_obj); + }; } Qstr::MP_QSTR_is_type_of => { // Return the is_type_of bound method @@ -228,7 +234,9 @@ unsafe extern "C" fn msg_def_obj_attr(self_in: Obj, attr: ffi::qstr, dest: *mut dest.offset(1).write(self_in); } } - _ => { return Err(Error::Missing); } + _ => { + return Err(Error::Missing); + } } Ok(()) }); @@ -261,7 +269,8 @@ unsafe extern "C" fn msg_def_obj_is_type_of(self_in: Obj, obj: Obj) -> Obj { }) } -static MSG_DEF_OBJ_IS_TYPE_OF_OBJ: ffi::mp_obj_fun_builtin_fixed_t = obj_fn_2!(msg_def_obj_is_type_of); +static MSG_DEF_OBJ_IS_TYPE_OF_OBJ: ffi::mp_obj_fun_builtin_fixed_t = + obj_fn_2!(msg_def_obj_is_type_of); #[no_mangle] pub extern "C" fn protobuf_debug_msg_type() -> &'static Type {