pub struct MessageTypeField(/* private fields */);Expand description
MessageType and associated flags packed into a single byte.
Implementations§
Source§impl MessageTypeField
impl MessageTypeField
Sourcepub const fn new(value: u8) -> Self
pub const fn new(value: u8) -> Self
Creates a new MessageTypeField with the given value.
§Examples
use rsomeip_proto::MessageTypeField;
let value = MessageTypeField::new(1 as u8);
assert_eq!(value.as_u8(), 1 as u8);Source§impl MessageTypeField
impl MessageTypeField
Sourcepub const TP_FLAG: u8 = 0x20
pub const TP_FLAG: u8 = 0x20
Transport Protocol flag. Determines if the message is a segment of a larger message.
Sourcepub const ALL_FLAGS: u8 = Self::TP_FLAG
pub const ALL_FLAGS: u8 = Self::TP_FLAG
A mask of all MessageTypeField flags.
Sourcepub const fn is_tp(&self) -> bool
pub const fn is_tp(&self) -> bool
Whether the Transport Protocol flag is set.
§Examples
use rsomeip_proto::MessageTypeField;
assert!(!MessageTypeField::new(0).is_tp());
assert!(MessageTypeField::new(MessageTypeField::TP_FLAG).is_tp());Sourcepub const fn flags(self) -> u8
pub const fn flags(self) -> u8
Returns the mask of all currently enabled flags.
§Examples
use rsomeip_proto::MessageTypeField;
let mask = MessageTypeField::new(MessageTypeField::TP_FLAG).flags();
assert_eq!(mask, MessageTypeField::TP_FLAG);Sourcepub const fn with_flags(self, flags: u8, enabled: bool) -> Self
pub const fn with_flags(self, flags: u8, enabled: bool) -> Self
Returns this MessageTypeField with the given flags set to enabled.
§Examples
use rsomeip_proto::MessageTypeField;
let field = MessageTypeField::default()
.with_flags(MessageTypeField::TP_FLAG, true);
assert_eq!(field.flags(), MessageTypeField::TP_FLAG);
let field = field.with_flags(MessageTypeField::TP_FLAG, false);
assert_eq!(field.flags(), 0);Sourcepub const fn as_type(self) -> MessageType
pub const fn as_type(self) -> MessageType
Returns the MessageType representation of this MessageTypeField.
Ignores all flags.
§Examples
use rsomeip_proto::{MessageType, MessageTypeField};
let field = MessageTypeField::new(0x80);
assert_eq!(field.as_type(), MessageType::Response);Sourcepub const fn from_type(value: MessageType) -> Self
pub const fn from_type(value: MessageType) -> Self
Creates a new MessageTypeField from the given MessageType.
§Examples
use rsomeip_proto::{MessageType, MessageTypeField};
let field = MessageTypeField::from_type(MessageType::Response);
assert_eq!(field.as_u8(), 0x80);Trait Implementations§
Source§impl Clone for MessageTypeField
impl Clone for MessageTypeField
Source§fn clone(&self) -> MessageTypeField
fn clone(&self) -> MessageTypeField
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MessageTypeField
impl Debug for MessageTypeField
Source§impl Default for MessageTypeField
impl Default for MessageTypeField
Source§fn default() -> MessageTypeField
fn default() -> MessageTypeField
Returns the “default value” for a type. Read more
Source§impl Deserialize for MessageTypeField
impl Deserialize for MessageTypeField
Source§type Output = MessageTypeField
type Output = MessageTypeField
Type of the data that will be deserialized.
Source§fn deserialize(buffer: &mut impl Buf) -> Result<Self::Output, DeserializeError>
fn deserialize(buffer: &mut impl Buf) -> Result<Self::Output, DeserializeError>
Deserializes an instance of
Deserialize::Output from the buffer. Read moreSource§fn deserialize_len(
length: LengthField,
buffer: &mut impl Buf,
) -> Result<Self::Output, DeserializeError>
fn deserialize_len( length: LengthField, buffer: &mut impl Buf, ) -> Result<Self::Output, DeserializeError>
Deserializes an instance of
Deserialize::Output from the buffer. Read moreSource§impl Display for MessageTypeField
impl Display for MessageTypeField
Source§impl From<MessageTypeField> for u8
impl From<MessageTypeField> for u8
Source§fn from(value: MessageTypeField) -> Self
fn from(value: MessageTypeField) -> Self
Converts to this type from the input type.
Source§impl From<u8> for MessageTypeField
impl From<u8> for MessageTypeField
Source§impl PartialEq for MessageTypeField
impl PartialEq for MessageTypeField
Source§impl Serialize for MessageTypeField
impl Serialize for MessageTypeField
Source§fn serialize(&self, buffer: &mut impl BufMut) -> Result<usize, SerializeError>
fn serialize(&self, buffer: &mut impl BufMut) -> Result<usize, SerializeError>
Serializes the implementing type into the buffer. Read more
Source§fn serialize_len(
&self,
length: LengthField,
buffer: &mut impl BufMut,
) -> Result<usize, SerializeError>
fn serialize_len( &self, length: LengthField, buffer: &mut impl BufMut, ) -> Result<usize, SerializeError>
Serializes the implementing type into the buffer. Read more
impl Copy for MessageTypeField
impl Eq for MessageTypeField
impl StructuralPartialEq for MessageTypeField
Auto Trait Implementations§
impl Freeze for MessageTypeField
impl RefUnwindSafe for MessageTypeField
impl Send for MessageTypeField
impl Sync for MessageTypeField
impl Unpin for MessageTypeField
impl UnsafeUnpin for MessageTypeField
impl UnwindSafe for MessageTypeField
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more