TopicValidator

Trait TopicValidator 

Source
pub trait TopicValidator: Send + Sync {
    // Required methods
    fn validate_topic_name(&self, topic: &str) -> Result<()>;
    fn validate_topic_filter(&self, filter: &str) -> Result<()>;
    fn is_reserved_topic(&self, topic: &str) -> bool;
    fn description(&self) -> &'static str;
}
Expand description

Trait for pluggable topic validation

This trait allows customization of topic validation rules beyond the standard MQTT specification. Implementations can add additional restrictions, reserved topic prefixes, or cloud provider-specific rules.

Required Methods§

Source

fn validate_topic_name(&self, topic: &str) -> Result<()>

Validates a topic name for publishing

§Arguments
  • topic - The topic name to validate
§Errors

Returns MqttError::InvalidTopicName if the topic is invalid

Source

fn validate_topic_filter(&self, filter: &str) -> Result<()>

Validates a topic filter for subscriptions

§Arguments
  • filter - The topic filter to validate
§Errors

Returns MqttError::InvalidTopicFilter if the filter is invalid

Source

fn is_reserved_topic(&self, topic: &str) -> bool

Checks if a topic is reserved and should be restricted

§Arguments
  • topic - The topic to check
§Returns

true if the topic is reserved and should be restricted

Source

fn description(&self) -> &'static str

Gets a human-readable description of the validator

Implementors§