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§

§

impl TopicFilter

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

Creates 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.

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

Validates and creates a new topic filter from a validated MqttStr.

§Errors

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

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

Views the topic filter as an MqttStr.

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

Views the topic filter as a string slice.

Trait Implementations§

§

impl AsRef<MqttStr> for TopicFilter

§

fn as_ref(&self) -> &MqttStr

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

impl AsRef<TopicFilter> for TopicFilterBuf

Available on crate feature alloc only.
§

fn as_ref(&self) -> &TopicFilter

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

impl AsRef<str> for TopicFilter

§

fn as_ref(&self) -> &str

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

impl Borrow<TopicFilter> for TopicFilterBuf

Available on crate feature alloc only.
§

fn borrow(&self) -> &TopicFilter

Immutably borrows from an owned value. Read more
§

impl Debug for TopicFilter

§

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

Formats the value using the given formatter. Read more
§

impl Display for TopicFilter

§

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

Formats the value using the given formatter. Read more
§

impl<'a> Extend<&'a TopicFilter> for TopicFiltersBuf

Available on crate feature alloc only.
§

fn extend<I: IntoIterator<Item = &'a TopicFilter>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
§

impl From<&TopicFilter> for Arc<TopicFilter>

Available on crate feature alloc only.
§

fn from(f: &TopicFilter) -> Self

Converts to this type from the input type.
§

impl From<&TopicFilter> for TopicFilterBuf

Available on crate feature alloc only.
§

fn from(value: &TopicFilter) -> Self

Converts to this type from the input type.
§

impl<'a> FromIterator<&'a TopicFilter> for TopicFiltersBuf

Available on crate feature alloc only.
§

fn from_iter<I: IntoIterator<Item = &'a TopicFilter>>(iter: I) -> Self

Creates a value from an iterator. Read more
§

impl Hash for TopicFilter

§

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

Feeds this value into the given Hasher. Read more
§

impl Ord for TopicFilter

§

fn cmp(&self, other: &TopicFilter) -> Ordering

This method returns an Ordering between self and other. Read more
§

impl PartialEq for TopicFilter

§

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.
§

impl PartialOrd for TopicFilter

§

fn partial_cmp(&self, other: &TopicFilter) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl ToOwned for TopicFilter

Available on crate feature alloc only.
§

type Owned = TopicFilterBuf

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> Self::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
§

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

§

type Error = ParseTopicError

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

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

Performs the conversion.
§

impl Eq for TopicFilter

§

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