trezor_client/messages/
mod.rs

1//! This module implements the `message_type` getter for all protobuf message types.
2
3use crate::protos::{MessageType::*, *};
4
5/// Extends the protobuf Message trait to also have a static getter for the message
6/// type code.
7pub trait TrezorMessage: protobuf::Message + std::fmt::Debug {
8    const MESSAGE_TYPE: MessageType;
9
10    #[inline]
11    #[deprecated(note = "Use `MESSAGE_TYPE` instead")]
12    fn message_type() -> MessageType {
13        Self::MESSAGE_TYPE
14    }
15}
16
17/// This macro provides the TrezorMessage trait for a protobuf message.
18macro_rules! trezor_message_impl {
19    ($($struct:ident => $mtype:expr),+ $(,)?) => {$(
20        impl TrezorMessage for $struct {
21            const MESSAGE_TYPE: MessageType = $mtype;
22        }
23    )+};
24}
25
26include!("./generated.rs");