pub struct UserProperty { /* private fields */ }
Implementations§
Source§impl UserProperty
impl UserProperty
Source§impl UserProperty
impl UserProperty
Sourcepub fn parse(bytes: &[u8]) -> Result<(Self, usize), MqttError>
pub fn parse(bytes: &[u8]) -> Result<(Self, usize), MqttError>
Parses a string pair property from the given byte slice.
§Parameters
bytes
- The byte slice to parse from
§Returns
Ok((Self, usize))
- The parsed property and number of bytes consumedErr(MqttError)
- If parsing fails
§Examples
ⓘ
let data = &[0x00, 0x03, b'k', b'e', b'y', 0x00, 0x05, b'v', b'a', b'l', b'u', b'e'];
let (prop, consumed) = UserProperty::parse(data).unwrap();
assert_eq!(consumed, 12);
Sourcepub fn to_buffers(&self) -> Vec<IoSlice<'_>>
pub fn to_buffers(&self) -> Vec<IoSlice<'_>>
Sourcepub fn to_continuous_buffer(&self) -> Vec<u8> ⓘ
pub fn to_continuous_buffer(&self) -> Vec<u8> ⓘ
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the total size of this property in bytes.
This includes the property ID (1 byte) plus both key and value string sizes.
§Returns
The total size in bytes.
§Examples
ⓘ
let prop = UserProperty::new("key", "value").unwrap();
assert_eq!(prop.size(), 13); // 1 (ID) + 2 (key len) + 3 (key) + 2 (val len) + 5 (val)
Trait Implementations§
Source§impl Clone for UserProperty
impl Clone for UserProperty
Source§fn clone(&self) -> UserProperty
fn clone(&self) -> UserProperty
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 UserProperty
impl Debug for UserProperty
Source§impl Display for UserProperty
impl Display for UserProperty
Source§impl From<UserProperty> for Property
impl From<UserProperty> for Property
Source§fn from(v: UserProperty) -> Self
fn from(v: UserProperty) -> Self
Converts to this type from the input type.
Source§impl PartialEq for UserProperty
impl PartialEq for UserProperty
Source§impl Serialize for UserProperty
impl Serialize for UserProperty
impl Eq for UserProperty
impl StructuralPartialEq for UserProperty
Auto Trait Implementations§
impl Freeze for UserProperty
impl RefUnwindSafe for UserProperty
impl Send for UserProperty
impl Sync for UserProperty
impl Unpin for UserProperty
impl UnwindSafe for UserProperty
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.