TopicFilter

Struct TopicFilter 

#[repr(transparent)]
pub struct TopicFilter(MqttStr);
Expand description

A validated, borrowed MQTT topic filter.

Topic filters are used in SUBSCRIBE / UNSUBSCRIBE packets and may contain the single-level wildcard + and the multi-level wildcard #. The filter must not be empty and must satisfy MqttStr constraints.

This is an unsized type like str. Use &TopicFilter for borrowed references and TopicFilterBuf for owned values.

Tuple Fields§

§0: MqttStr

Implementations§

Source§

impl TopicFilter

Source

pub const unsafe fn new_unchecked(s: &MqttStr) -> &TopicFilter

Create a topic filter without validating filter-specific invariants.

§Safety

The caller must guarantee that s satisfies the topic filter invariants: non-empty, valid wildcard placement, and valid MqttStr.

Source

pub const fn new(s: &MqttStr) -> Result<&TopicFilter, TopicError>

Validate and create a new topic filter from a validated MqttStr.

§Errors

Returns TopicError if the string is empty or has invalid wildcard placement.

Source

pub const fn as_mqtt_str(&self) -> &MqttStr

Views the topic filter as an MqttStr.

Source

pub const fn as_str(&self) -> &str

Views the topic filter as a string slice.

Trait Implementations§

Source§

impl AsRef<MqttStr> for TopicFilter

Source§

fn as_ref(&self) -> &MqttStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<TopicFilter> for TopicFilterBuf

Source§

fn as_ref(&self) -> &TopicFilter

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for TopicFilter

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<TopicFilter> for TopicFilterBuf

Source§

fn borrow(&self) -> &TopicFilter

Immutably borrows from an owned value. Read more
Source§

impl Debug for TopicFilter

Source§

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

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

impl Display for TopicFilter

Source§

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

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

impl From<&TopicFilter> for TopicFilterBuf

Source§

fn from(value: &TopicFilter) -> TopicFilterBuf

Converts to this type from the input type.
Source§

impl Hash for TopicFilter

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq for TopicFilter

Source§

fn eq(&self, other: &TopicFilter) -> 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 ToOwned for TopicFilter

Source§

type Owned = TopicFilterBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> <TopicFilter as ToOwned>::Owned

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

fn clone_into(&self, target: &mut Self::Owned)

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

impl<'a> TryFrom<&'a str> for &'a TopicFilter

Source§

type Error = ParseTopicError

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

fn try_from( value: &'a str, ) -> Result<&'a TopicFilter, <&'a TopicFilter as TryFrom<&'a str>>::Error>

Performs the conversion.
Source§

impl Eq for TopicFilter

Source§

impl StructuralPartialEq for TopicFilter

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
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more