pub struct SimulcryptMessage<'a> {
pub protocol_version: u8,
pub message_type: MessageType,
pub parameters: Vec<Parameter<'a>>,
}Expand description
A generic SimulCrypt message (TS 103 197 Table 1b): the 5-byte header plus
an ordered list of TLV Parameters.
The Interface is not on the wire — it is fixed by the TCP connection the
message arrived on, and is supplied to SimulcryptMessage::parse_on so the
raw message_type/parameter_type values can be decoded into the right
interface-scoped registry.
Fields§
§protocol_version: u8protocol_version (Table 2; 0x03 for both implemented interfaces).
message_type: MessageTypeThe interface-tagged message_type.
parameters: Vec<Parameter<'a>>The TLV parameter list, in wire order (order is not significant per NOTE 2, but is preserved for byte-exact round-tripping).
Implementations§
Source§impl<'a> SimulcryptMessage<'a>
impl<'a> SimulcryptMessage<'a>
Sourcepub fn new(
protocol_version: u8,
message_type: MessageType,
parameters: Vec<Parameter<'a>>,
) -> Self
pub fn new( protocol_version: u8, message_type: MessageType, parameters: Vec<Parameter<'a>>, ) -> Self
Construct a message from typed fields.
Sourcepub const fn interface(&self) -> Interface
pub const fn interface(&self) -> Interface
The interface this message was decoded against (from its message_type).
Sourcepub fn body_len(&self) -> usize
pub fn body_len(&self) -> usize
Sum of the wire lengths of every parameter TLV — i.e. the value the
message_length field will carry on serialize.
Sourcepub fn find(&self, ptype: ParameterType) -> Option<&Parameter<'a>>
pub fn find(&self, ptype: ParameterType) -> Option<&Parameter<'a>>
Find the first parameter whose parameter_type matches ptype.
Sourcepub fn parse_on(iface: Interface, bytes: &'a [u8]) -> Result<Self>
pub fn parse_on(iface: Interface, bytes: &'a [u8]) -> Result<Self>
Parse a message off the wire, decoding message_type/parameter_type
against the given Interface (the connection’s interface).
§Errors
Returns Error::BufferTooShort if the header or a TLV header is
truncated, Error::InvalidMessageLength if message_length overruns
the buffer, and Error::TruncatedParameter if a parameter_length
runs past the message body.
Trait Implementations§
Source§impl<'a> Clone for SimulcryptMessage<'a>
impl<'a> Clone for SimulcryptMessage<'a>
Source§fn clone(&self) -> SimulcryptMessage<'a>
fn clone(&self) -> SimulcryptMessage<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for SimulcryptMessage<'a>
impl<'a> Debug for SimulcryptMessage<'a>
impl<'a> Eq for SimulcryptMessage<'a>
Source§impl<'a> Parse<'a> for SimulcryptMessage<'a>
impl<'a> Parse<'a> for SimulcryptMessage<'a>
Source§impl<'a> PartialEq for SimulcryptMessage<'a>
impl<'a> PartialEq for SimulcryptMessage<'a>
Source§impl<'a> Serialize for SimulcryptMessage<'a>
Available on crate feature serde only.
impl<'a> Serialize for SimulcryptMessage<'a>
serde only.Source§impl Serialize for SimulcryptMessage<'_>
impl Serialize for SimulcryptMessage<'_>
Source§type Error = Error
type Error = Error
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
serialize_into will write.