Skip to main content

DomainMessage

Trait DomainMessage 

Source
pub trait DomainMessage: RingMessage {
    // Required method
    fn domain() -> Domain;

    // Provided methods
    fn domain_type_id() -> u64 { ... }
    fn is_valid_domain_type_id() -> bool { ... }
}
Expand description

Trait for messages that belong to a specific business domain.

This trait is automatically implemented by the #[derive(RingMessage)] macro when a domain attribute is specified.

§Example

#[derive(RingMessage)]
#[ring_message(type_id = 1, domain = "OrderMatching")]
pub struct SubmitOrder {
    #[message(id)]
    id: MessageId,
    symbol: String,
}

// Auto-generated:
impl DomainMessage for SubmitOrder {
    fn domain() -> Domain { Domain::OrderMatching }
}

Required Methods§

Source

fn domain() -> Domain

Get the domain this message belongs to.

Provided Methods§

Source

fn domain_type_id() -> u64

Get the type ID offset within the domain (0-99).

This is calculated as: message_type() - domain().base_type_id()

Source

fn is_valid_domain_type_id() -> bool

Check if this message type is within its domain’s valid range.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§