pub struct ValidatedTopic(/* private fields */);Expand description
A newtype wrapper that guarantees its inner String is a valid MQTT topic.
This type prevents the cost of repeated validation for topics that are used
frequently. It can only be constructed via ValidatedTopic::new, which
performs a one-time validation check.
Use this when publishing repeatedly to the same topic to avoid per-call
validation overhead in publish APIs that accept PublishTopic.
Implementations§
Source§impl ValidatedTopic
impl ValidatedTopic
Sourcepub fn new<S: Into<String>>(topic: S) -> Result<Self, InvalidTopic>
pub fn new<S: Into<String>>(topic: S) -> Result<Self, InvalidTopic>
Constructs a new ValidatedTopic after validating the input string.
§Errors
Returns InvalidTopic if the topic string does not conform to the MQTT specification.
Trait Implementations§
Source§impl Clone for ValidatedTopic
impl Clone for ValidatedTopic
Source§fn clone(&self) -> ValidatedTopic
fn clone(&self) -> ValidatedTopic
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidatedTopic
impl Debug for ValidatedTopic
Source§impl From<ValidatedTopic> for PublishTopic
impl From<ValidatedTopic> for PublishTopic
Source§fn from(topic: ValidatedTopic) -> Self
fn from(topic: ValidatedTopic) -> Self
Converts to this type from the input type.
Source§impl From<ValidatedTopic> for String
impl From<ValidatedTopic> for String
Source§fn from(topic: ValidatedTopic) -> Self
fn from(topic: ValidatedTopic) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ValidatedTopic
impl PartialEq for ValidatedTopic
impl Eq for ValidatedTopic
impl StructuralPartialEq for ValidatedTopic
Auto Trait Implementations§
impl Freeze for ValidatedTopic
impl RefUnwindSafe for ValidatedTopic
impl Send for ValidatedTopic
impl Sync for ValidatedTopic
impl Unpin for ValidatedTopic
impl UnsafeUnpin for ValidatedTopic
impl UnwindSafe for ValidatedTopic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more