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

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.

pub const fn new(s: &MqttStr) -> Result<&Self, 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.

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 From<&TopicFilter> for TopicFilterBuf

Available on crate feature alloc only.
§

fn from(value: &TopicFilter) -> Self

Converts to this type from the input type.
§

impl Hash for TopicFilter

§

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

Feeds this value into the given Hasher. 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 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