pub enum DMSCFrameType {
Control = 1,
Data = 2,
Auth = 3,
KeepAlive = 4,
Error = 5,
Encrypted = 6,
}Expand description
Protocol frame type enumeration defining the categories of protocol frames.
This enumeration classifies all protocol frames used in the DMSC protocol for network communication. Each frame type serves a specific purpose in the communication lifecycle, from initial connection establishment through data transmission, authentication, and connection maintenance. Frame type identification enables proper routing and processing of incoming frames by protocol handlers.
§Frame Type Hierarchy
- Control Frames (0x01): Protocol management and state transitions
- Data Frames (0x02): Application data payload transmission
- Auth Frames (0x03): Authentication and authorization exchanges
- Keep-Alive Frames (0x04): Connection liveness verification
- Error Frames (0x05): Error reporting and status communication
- Encrypted Frames (0x06): Pre-encrypted payload transmission
§Frame Processing Guidelines
Protocol implementations should process frames in the following order:
- First validate the frame header magic number and version
- Extract and validate the frame type from the header
- Route the frame to the appropriate handler based on frame type
- Process the frame payload according to type-specific rules
- Send appropriate response frames if required
§Python Bindings
When compiled with the pyo3 feature, this enum provides Python bindings
for frame type identification:
from dmsc import DMSCFrameType
# Identify frame types for protocol handling
control_type = DMSCFrameType.Control()
data_type = DMSCFrameType.Data()
auth_type = DMSCFrameType.Auth()
# Convert between types and byte values
frame_type_value = DMSCFrameType.from_u8(0x01)
byte_value = data_type.to_u8() # Returns 0x02§Thread Safety
This enum is fully thread-safe and can be shared across concurrent contexts without additional synchronization. The Copy trait enables efficient passing of frame type values through function arguments and return types.
§Storage and Transmission
Frame type values are stored as single bytes making them efficient for network transmission and compact storage. The Hash trait enables frame type usage as dictionary keys in collection types and provides efficient lookup performance.
§Examples
Basic frame type creation and conversion:
use dmsc::protocol::frames::DMSCFrameType;
let control = DMSCFrameType::Control;
let data = DMSCFrameType::Data;
assert_eq!(control as u8, 0x01);
assert_eq!(data as u8, 0x02);
assert_ne!(control, data);Frame type matching in protocol handling:
use dmsc::protocol::frames::DMSCFrameType;
fn handle_frame_type(frame_type: DMSCFrameType) -> &str {
match frame_type {
DMSCFrameType::Control => "Control frame - managing protocol state",
DMSCFrameType::Data => "Data frame - processing payload",
DMSCFrameType::Auth => "Auth frame - handling authentication",
DMSCFrameType::KeepAlive => "Keep-alive frame - verifying connection",
DMSCFrameType::Error => "Error frame - reporting error condition",
DMSCFrameType::Encrypted => "Encrypted frame - processing secure payload",
}
}
assert_eq!(handle_frame_type(DMSCFrameType::Data), "Data frame - processing payload");Converting between byte values and frame types:
use dmsc::protocol::frames::DMSCFrameType;
// Convert byte to frame type
let frame_type = DMSCFrameType::from_u8(0x03);
assert_eq!(frame_type, Some(DMSCFrameType::Auth));
// Invalid byte value returns None
let invalid = DMSCFrameType::from_u8(0xFF);
assert_eq!(invalid, None);Variants§
Control = 1
Control frame for protocol management operations.
Control frames manage the protocol state machine and handle connection lifecycle events. They are used for operations such as connection initialization, version negotiation, feature flags exchange, and graceful connection termination. Control frames must be processed before any data frames to ensure proper protocol state establishment.
§Control Frame Payload Structure
Control frame payloads contain a command identifier followed by command-specific parameters encoded in a type-length-value (TLV) format.
§Common Control Commands
- Connection Request (0x01): Initiate new connection
- Connection Ack (0x02): Confirm connection establishment
- Disconnect Request (0x03): Initiate graceful disconnection
- Ping (0x04): Request keep-alive response
- Pong (0x05): Keep-alive response
- Protocol Negotiation (0x10): Negotiate protocol features
Data = 2
Data frame for application payload transmission.
Data frames carry the primary application data through the protocol. They are the most frequently used frame type in normal protocol operation and support both streaming and message-based data transfer modes. Data frames are sequenced and delivered in-order to ensure data integrity.
§Data Frame Characteristics
- Sequencing: Each data frame has a unique sequence number
- Ordering: Frames are delivered in sequence number order
- Flow Control: Sliding window prevents buffer overflow
- Aggregation: Multiple small payloads can be aggregated
§Payload Considerations
- Maximum payload size is defined by protocol configuration
- Large payloads may be fragmented across multiple frames
- Payload compression is available as an optional feature
Auth = 3
Authentication frame for credential exchange and verification.
Authentication frames facilitate the authentication process between communicating parties. They carry authentication tokens, certificates, challenge-response pairs, and authentication results. All auth frames are encrypted using the current session encryption keys.
§Authentication Flow
- Client sends authentication request with credentials
- Server validates credentials and returns challenge
- Client responds to challenge with proof of possession
- Server confirms successful authentication
§Supported Authentication Methods
- JWT token authentication
- Certificate-based mutual TLS
- Pre-shared key authentication
- OAuth 2.0 token exchange
KeepAlive = 4
Keep-alive frame for connection liveness verification.
Keep-alive frames maintain connection vitality and detect unresponsive peers. They are exchanged periodically between connected parties to prevent connection timeout and detect connection failures. Keep-alive frames have minimal overhead and contain no payload.
Error = 5
Error frame for error condition reporting.
Error frames communicate error conditions from one protocol party to another. They include an error code and human-readable error message to facilitate debugging and error recovery. Error frames may be sent in response to any invalid protocol message.
Encrypted = 6
Encrypted frame for pre-encrypted payload transmission.
Encrypted frames carry payloads that have been encrypted by the application layer before being passed to the protocol. This allows applications to use custom encryption schemes or to encrypt data end-to-end between application endpoints. The protocol encrypts the encrypted payload as normal data.
§Use Cases
- End-to-end encrypted application data
- Custom encryption algorithm requirements
- Regulatory compliance requiring specific encryption
- Integration with external encryption systems
§Security Considerations
When using encrypted frames, the outer protocol encryption provides transport security while the inner encrypted payload provides end-to-end security between application endpoints.
Implementations§
Trait Implementations§
Source§impl Clone for DMSCFrameType
impl Clone for DMSCFrameType
Source§fn clone(&self) -> DMSCFrameType
fn clone(&self) -> DMSCFrameType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DMSCFrameType
impl Debug for DMSCFrameType
Source§impl<'py> IntoPyObject<'py> for DMSCFrameType
impl<'py> IntoPyObject<'py> for DMSCFrameType
Source§type Target = DMSCFrameType
type Target = DMSCFrameType
Source§type Output = Bound<'py, <DMSCFrameType as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <DMSCFrameType as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PartialEq for DMSCFrameType
impl PartialEq for DMSCFrameType
Source§impl PyClass for DMSCFrameType
impl PyClass for DMSCFrameType
Source§impl PyClassImpl for DMSCFrameType
impl PyClassImpl for DMSCFrameType
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = c"Protocol frame type enumeration defining the categories of protocol frames.\n\nThis enumeration classifies all protocol frames used in the DMSC protocol\nfor network communication. Each frame type serves a specific purpose in\nthe communication lifecycle, from initial connection establishment through\ndata transmission, authentication, and connection maintenance. Frame type\nidentification enables proper routing and processing of incoming frames\nby protocol handlers.\n\n## Frame Type Hierarchy\n\n- **Control Frames (0x01)**: Protocol management and state transitions\n- **Data Frames (0x02)**: Application data payload transmission\n- **Auth Frames (0x03)**: Authentication and authorization exchanges\n- **Keep-Alive Frames (0x04)**: Connection liveness verification\n- **Error Frames (0x05)**: Error reporting and status communication\n- **Encrypted Frames (0x06)**: Pre-encrypted payload transmission\n\n## Frame Processing Guidelines\n\nProtocol implementations should process frames in the following order:\n1. First validate the frame header magic number and version\n2. Extract and validate the frame type from the header\n3. Route the frame to the appropriate handler based on frame type\n4. Process the frame payload according to type-specific rules\n5. Send appropriate response frames if required\n\n## Python Bindings\n\nWhen compiled with the `pyo3` feature, this enum provides Python bindings\nfor frame type identification:\n```python\nfrom dmsc import DMSCFrameType\n\n# Identify frame types for protocol handling\ncontrol_type = DMSCFrameType.Control()\ndata_type = DMSCFrameType.Data()\nauth_type = DMSCFrameType.Auth()\n\n# Convert between types and byte values\nframe_type_value = DMSCFrameType.from_u8(0x01)\nbyte_value = data_type.to_u8() # Returns 0x02\n```\n\n## Thread Safety\n\nThis enum is fully thread-safe and can be shared across concurrent contexts\nwithout additional synchronization. The Copy trait enables efficient passing\nof frame type values through function arguments and return types.\n\n## Storage and Transmission\n\nFrame type values are stored as single bytes making them efficient for network\ntransmission and compact storage. The Hash trait enables frame type usage as\ndictionary keys in collection types and provides efficient lookup performance.\n\n# Examples\n\nBasic frame type creation and conversion:\n```rust,ignore\nuse dmsc::protocol::frames::DMSCFrameType;\n\nlet control = DMSCFrameType::Control;\nlet data = DMSCFrameType::Data;\n\nassert_eq!(control as u8, 0x01);\nassert_eq!(data as u8, 0x02);\nassert_ne!(control, data);\n```\n\nFrame type matching in protocol handling:\n```rust,ignore\nuse dmsc::protocol::frames::DMSCFrameType;\n\nfn handle_frame_type(frame_type: DMSCFrameType) -> &str {\n match frame_type {\n DMSCFrameType::Control => \"Control frame - managing protocol state\",\n DMSCFrameType::Data => \"Data frame - processing payload\",\n DMSCFrameType::Auth => \"Auth frame - handling authentication\",\n DMSCFrameType::KeepAlive => \"Keep-alive frame - verifying connection\",\n DMSCFrameType::Error => \"Error frame - reporting error condition\",\n DMSCFrameType::Encrypted => \"Encrypted frame - processing secure payload\",\n }\n}\n\nassert_eq!(handle_frame_type(DMSCFrameType::Data), \"Data frame - processing payload\");\n```\n\nConverting between byte values and frame types:\n```rust,ignore\nuse dmsc::protocol::frames::DMSCFrameType;\n\n// Convert byte to frame type\nlet frame_type = DMSCFrameType::from_u8(0x03);\nassert_eq!(frame_type, Some(DMSCFrameType::Auth));\n\n// Invalid byte value returns None\nlet invalid = DMSCFrameType::from_u8(0xFF);\nassert_eq!(invalid, None);\n```\x00"
const RAW_DOC: &'static CStr = c"Protocol frame type enumeration defining the categories of protocol frames.\n\nThis enumeration classifies all protocol frames used in the DMSC protocol\nfor network communication. Each frame type serves a specific purpose in\nthe communication lifecycle, from initial connection establishment through\ndata transmission, authentication, and connection maintenance. Frame type\nidentification enables proper routing and processing of incoming frames\nby protocol handlers.\n\n## Frame Type Hierarchy\n\n- **Control Frames (0x01)**: Protocol management and state transitions\n- **Data Frames (0x02)**: Application data payload transmission\n- **Auth Frames (0x03)**: Authentication and authorization exchanges\n- **Keep-Alive Frames (0x04)**: Connection liveness verification\n- **Error Frames (0x05)**: Error reporting and status communication\n- **Encrypted Frames (0x06)**: Pre-encrypted payload transmission\n\n## Frame Processing Guidelines\n\nProtocol implementations should process frames in the following order:\n1. First validate the frame header magic number and version\n2. Extract and validate the frame type from the header\n3. Route the frame to the appropriate handler based on frame type\n4. Process the frame payload according to type-specific rules\n5. Send appropriate response frames if required\n\n## Python Bindings\n\nWhen compiled with the `pyo3` feature, this enum provides Python bindings\nfor frame type identification:\n```python\nfrom dmsc import DMSCFrameType\n\n# Identify frame types for protocol handling\ncontrol_type = DMSCFrameType.Control()\ndata_type = DMSCFrameType.Data()\nauth_type = DMSCFrameType.Auth()\n\n# Convert between types and byte values\nframe_type_value = DMSCFrameType.from_u8(0x01)\nbyte_value = data_type.to_u8() # Returns 0x02\n```\n\n## Thread Safety\n\nThis enum is fully thread-safe and can be shared across concurrent contexts\nwithout additional synchronization. The Copy trait enables efficient passing\nof frame type values through function arguments and return types.\n\n## Storage and Transmission\n\nFrame type values are stored as single bytes making them efficient for network\ntransmission and compact storage. The Hash trait enables frame type usage as\ndictionary keys in collection types and provides efficient lookup performance.\n\n# Examples\n\nBasic frame type creation and conversion:\n```rust,ignore\nuse dmsc::protocol::frames::DMSCFrameType;\n\nlet control = DMSCFrameType::Control;\nlet data = DMSCFrameType::Data;\n\nassert_eq!(control as u8, 0x01);\nassert_eq!(data as u8, 0x02);\nassert_ne!(control, data);\n```\n\nFrame type matching in protocol handling:\n```rust,ignore\nuse dmsc::protocol::frames::DMSCFrameType;\n\nfn handle_frame_type(frame_type: DMSCFrameType) -> &str {\n match frame_type {\n DMSCFrameType::Control => \"Control frame - managing protocol state\",\n DMSCFrameType::Data => \"Data frame - processing payload\",\n DMSCFrameType::Auth => \"Auth frame - handling authentication\",\n DMSCFrameType::KeepAlive => \"Keep-alive frame - verifying connection\",\n DMSCFrameType::Error => \"Error frame - reporting error condition\",\n DMSCFrameType::Encrypted => \"Encrypted frame - processing secure payload\",\n }\n}\n\nassert_eq!(handle_frame_type(DMSCFrameType::Data), \"Data frame - processing payload\");\n```\n\nConverting between byte values and frame types:\n```rust,ignore\nuse dmsc::protocol::frames::DMSCFrameType;\n\n// Convert byte to frame type\nlet frame_type = DMSCFrameType::from_u8(0x03);\nassert_eq!(frame_type, Some(DMSCFrameType::Auth));\n\n// Invalid byte value returns None\nlet invalid = DMSCFrameType::from_u8(0xFF);\nassert_eq!(invalid, None);\n```\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<DMSCFrameType>
type ThreadChecker = SendablePyClass<DMSCFrameType>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyTypeInfo for DMSCFrameType
impl PyTypeInfo for DMSCFrameType
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl Copy for DMSCFrameType
impl Eq for DMSCFrameType
impl ExtractPyClassWithClone for DMSCFrameType
impl StructuralPartialEq for DMSCFrameType
Auto Trait Implementations§
impl Freeze for DMSCFrameType
impl RefUnwindSafe for DMSCFrameType
impl Send for DMSCFrameType
impl Sync for DMSCFrameType
impl Unpin for DMSCFrameType
impl UnwindSafe for DMSCFrameType
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more