mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-05 22:32:33 +00:00
style(core): apply rustfmt
[no changelog]
This commit is contained in:
parent
c80c8edf70
commit
a007e062ab
@ -1,5 +1,5 @@
|
|||||||
use core::{mem, slice};
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
|
use core::{mem, slice};
|
||||||
|
|
||||||
pub struct MsgDef {
|
pub struct MsgDef {
|
||||||
pub fields: &'static [FieldDef],
|
pub fields: &'static [FieldDef],
|
||||||
@ -112,7 +112,8 @@ struct NameDef {
|
|||||||
|
|
||||||
static ENUM_DEFS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/../../../../proto_enums.data"));
|
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 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"));
|
static WIRE_DEFS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/../../../..//proto_wire.data"));
|
||||||
|
|
||||||
pub fn find_name_by_msg_offset(msg_offset: u16) -> Result<u16, Error> {
|
pub fn find_name_by_msg_offset(msg_offset: u16) -> Result<u16, Error> {
|
||||||
@ -123,7 +124,8 @@ pub fn find_name_by_msg_offset(msg_offset: u16) -> Result<u16, Error> {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
name_defs.iter()
|
name_defs
|
||||||
|
.iter()
|
||||||
.filter(|def| def.msg_offset == msg_offset)
|
.filter(|def| def.msg_offset == msg_offset)
|
||||||
.next()
|
.next()
|
||||||
.map(|def| def.msg_name)
|
.map(|def| def.msg_name)
|
||||||
|
@ -15,7 +15,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
defs::{FieldDef, FieldType, MsgDef},
|
defs::{FieldDef, FieldType, MsgDef},
|
||||||
obj::{MsgObj},
|
obj::MsgObj,
|
||||||
zigzag,
|
zigzag,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ impl MsgObj {
|
|||||||
match attr {
|
match attr {
|
||||||
Qstr::MP_QSTR_MESSAGE_WIRE_TYPE => {
|
Qstr::MP_QSTR_MESSAGE_WIRE_TYPE => {
|
||||||
// Return the wire ID of this message def, or None if not set.
|
// 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 => {
|
Qstr::MP_QSTR_MESSAGE_NAME => {
|
||||||
// Return the qstr name of this message def
|
// Return the qstr name of this message def
|
||||||
@ -79,7 +81,7 @@ impl MsgObj {
|
|||||||
// we're returning a mutable dict.
|
// we're returning a mutable dict.
|
||||||
Ok(Gc::new(Dict::with_map(self.map.clone())).into())
|
Ok(Gc::new(Dict::with_map(self.map.clone())).into())
|
||||||
}
|
}
|
||||||
_ => { Err(Error::Missing) }
|
_ => Err(Error::Missing),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 => {
|
Qstr::MP_QSTR_MESSAGE_NAME => {
|
||||||
// Return the qstr name of this message def
|
// Return the qstr name of this message def
|
||||||
let name = Qstr::from_u16(find_name_by_msg_offset(this.def.offset)?);
|
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 => {
|
Qstr::MP_QSTR_MESSAGE_WIRE_TYPE => {
|
||||||
// Return the wire type of this message def
|
// 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
|
.def
|
||||||
.wire_id
|
.wire_id
|
||||||
.map_or_else(Obj::const_none, |wire_id| wire_id.into());
|
.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 => {
|
Qstr::MP_QSTR_is_type_of => {
|
||||||
// Return the is_type_of bound method
|
// 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);
|
dest.offset(1).write(self_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => { return Err(Error::Missing); }
|
_ => {
|
||||||
|
return Err(Error::Missing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
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]
|
#[no_mangle]
|
||||||
pub extern "C" fn protobuf_debug_msg_type() -> &'static Type {
|
pub extern "C" fn protobuf_debug_msg_type() -> &'static Type {
|
||||||
|
Loading…
Reference in New Issue
Block a user