DMSCFrameType

Enum DMSCFrameType 

Source
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:

  1. First validate the frame header magic number and version
  2. Extract and validate the frame type from the header
  3. Route the frame to the appropriate handler based on frame type
  4. Process the frame payload according to type-specific rules
  5. 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
  1. Client sends authentication request with credentials
  2. Server validates credentials and returns challenge
  3. Client responds to challenge with proof of possession
  4. 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§

Source§

impl DMSCFrameType

Source

pub fn from_u8(value: u8) -> Option<Self>

Convert from byte to frame type

Trait Implementations§

Source§

impl Clone for DMSCFrameType

Source§

fn clone(&self) -> DMSCFrameType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DMSCFrameType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'py> IntoPyObject<'py> for DMSCFrameType

Source§

type Target = DMSCFrameType

The Python output type
Source§

type Output = Bound<'py, <DMSCFrameType as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PartialEq for DMSCFrameType

Source§

fn eq(&self, other: &DMSCFrameType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PyClass for DMSCFrameType

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for DMSCFrameType

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
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"

Docstring for the class provided on the struct or enum. Read more
Source§

const DOC: &'static CStr

Fully rendered class doc, including the text_signature if a constructor is defined. Read more
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<DMSCFrameType>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

Source§

impl PyTypeInfo for DMSCFrameType

Source§

const NAME: &'static str = "DMSCFrameType"

Class name.
Source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl Copy for DMSCFrameType

Source§

impl Eq for DMSCFrameType

Source§

impl ExtractPyClassWithClone for DMSCFrameType

Source§

impl StructuralPartialEq for DMSCFrameType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<'a, 'py, T> FromPyObject<'a, 'py> for T
where T: PyClass + Clone + ExtractPyClassWithClone,

§

type Error = PyClassGuardError<'a, 'py>

The type returned in the event of a conversion error. Read more
§

fn extract( obj: Borrowed<'a, 'py, PyAny>, ) -> Result<T, <T as FromPyObject<'a, 'py>>::Error>

Extracts Self from the bound smart pointer obj. Read more
§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 T
where T: IntoPyObject<'py>,

§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts 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>

Converts self into a Python object. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = T::NAME

👎Deprecated since 0.27.0: Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.
Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
§

fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>

Returns the expected type as a possible argument for the isinstance and issubclass function. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'py, T> FromPyObjectOwned<'py> for T
where T: for<'a> FromPyObject<'a, 'py>,

§

impl<T> Ungil for T
where T: Send,