pub struct FrameType(/* private fields */);Expand description
An MS/TP frame type: the first octet of the header after the preamble, which says what the frame is (Clause 9.3).
The set is open, so a decoder hands on every octet as it arrived and
a dispatcher matches the constants with a _ arm for the rest. The
constants are the ten types Clause 9.3 defines. Any other octet is
reserved (8-31), reserved and COBS-encoded (34-127), or proprietary
(128-255); FrameType::from_raw wraps it all the same, and two
frame types are equal when their octets are.
Frame types are numbered in decimal, as Clause 9.3 numbers them: the
constants’ wire values below, and Debug and Display for a type no
constant names.
use bacnet_mstp_codec::FrameType;
assert_eq!(FrameType::from_raw(0), FrameType::TOKEN);
assert_eq!(FrameType::TOKEN.name(), Some("TOKEN"));
// A proprietary type has no name, but keeps its octet.
let proprietary = FrameType::from_raw(128);
assert!(proprietary.is_proprietary() && !proprietary.is_defined());
assert_eq!(proprietary.to_raw(), 128);
assert_eq!(format!("{proprietary:?}"), "FrameType(128)");
assert_eq!(format!("{:?}", FrameType::TOKEN), "FrameType::TOKEN");Implementations§
Source§impl FrameType
impl FrameType
Sourcepub const TOKEN: Self
pub const TOKEN: Self
Token: passes the right to send to the next master (Clause 9.3.1).
Wire value 0.
Sourcepub const POLL_FOR_MASTER: Self
pub const POLL_FOR_MASTER: Self
Poll For Master: looks for a master at an address (Clause 9.3.2).
Wire value 1.
Sourcepub const REPLY_TO_POLL_FOR_MASTER: Self
pub const REPLY_TO_POLL_FOR_MASTER: Self
Reply To Poll For Master: a master answering a poll (Clause 9.3.3).
Wire value 2.
Sourcepub const TEST_REQUEST: Self
pub const TEST_REQUEST: Self
Test_Request: asks the receiver to send its data back (Clause 9.3.4).
Wire value 3.
Sourcepub const TEST_RESPONSE: Self
pub const TEST_RESPONSE: Self
Test_Response: the answer to a Test_Request (Clause 9.3.5).
Wire value 4.
Sourcepub const BACNET_DATA_EXPECTING_REPLY: Self
pub const BACNET_DATA_EXPECTING_REPLY: Self
BACnet Data Expecting Reply: an NPDU whose sender waits for an answer (Clause 9.3.6).
Wire value 5.
Sourcepub const BACNET_DATA_NOT_EXPECTING_REPLY: Self
pub const BACNET_DATA_NOT_EXPECTING_REPLY: Self
BACnet Data Not Expecting Reply: an NPDU that wants no answer (Clause 9.3.7).
Wire value 6.
Sourcepub const REPLY_POSTPONED: Self
pub const REPLY_POSTPONED: Self
Reply Postponed: puts off the answer to a BACnet Data Expecting Reply (Clause 9.3.8).
Wire value 7.
Sourcepub const BACNET_EXTENDED_DATA_EXPECTING_REPLY: Self
pub const BACNET_EXTENDED_DATA_EXPECTING_REPLY: Self
BACnet Extended Data Expecting Reply: an NPDU too long for a standard frame, COBS-encoded (Clause 9.3.9).
Wire value 32.
Sourcepub const BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY: Self
pub const BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY: Self
BACnet Extended Data Not Expecting Reply: an NPDU too long for a standard frame, COBS-encoded (Clause 9.3.10).
Wire value 33.
Sourcepub const ALL_NAMED: &[(&str, Self)]
pub const ALL_NAMED: &[(&str, Self)]
Every named constant, with its name, in the order declared.
Sourcepub const fn name(self) -> Option<&'static str>
pub const fn name(self) -> Option<&'static str>
The constant’s name, or None for a value the standard
doesn’t define.
Sourcepub const fn is_defined(self) -> bool
pub const fn is_defined(self) -> bool
Whether the standard defines this value.
Source§impl FrameType
impl FrameType
Sourcepub const fn allows_data(self) -> bool
pub const fn allows_data(self) -> bool
Whether a frame of this type may carry a data field.
False only for the four types defined without data:
TOKEN, POLL_FOR_MASTER,
REPLY_TO_POLL_FOR_MASTER and
REPLY_POSTPONED (Clauses 9.3.1-9.3.3, 9.3.8).
Every other type may, including the reserved types 8-31, which the
codec passes through without policing their content.
Sourcepub const fn is_cobs(self) -> bool
pub const fn is_cobs(self) -> bool
Whether this type is in the COBS-encoded range, 32-127 (Clause 9.3).
Its Length must fall within
MIN_COBS_LENGTH..=MAX_COBS_LENGTH (Clause 9.5.8).
Sourcepub const fn is_extended_data(self) -> bool
pub const fn is_extended_data(self) -> bool
Whether this is one of the two extended data types, 32 and 33: the
COBS-encoded types the codec encodes and decodes, which carry BACnet
NPDUs of 502 to MAX_EXTENDED_MPDU_DATA
octets (Clauses 9.3.9, 9.3.10). The rest of the COBS range, 34-127,
is reserved.
Sourcepub const fn is_proprietary(self) -> bool
pub const fn is_proprietary(self) -> bool
Whether this type is in the vendor-proprietary range, 128-255. Such a frame’s data opens with a 2-octet vendor identifier (Clause 9.3.11).