pub struct CorrelationData { /* private fields */ }
Implementations§
Source§impl CorrelationData
impl CorrelationData
Sourcepub fn new<T>(v: T) -> Result<Self, MqttError>
pub fn new<T>(v: T) -> Result<Self, MqttError>
Creates a new binary property with the given value.
§Parameters
v
- The binary value to set (can be any type that converts to bytes)
§Returns
Ok(Self)
- Successfully created propertyErr(MqttError)
- If the binary data is invalid or too large
§Examples
ⓘ
let prop = CorrelationData::new(b"correlation-123").unwrap();
Sourcepub fn parse(bytes: &[u8]) -> Result<(Self, usize), MqttError>
pub fn parse(bytes: &[u8]) -> Result<(Self, usize), MqttError>
Parses a binary 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, 0x05, b'h', b'e', b'l', b'l', b'o'];
let (prop, consumed) = CorrelationData::parse(data).unwrap();
assert_eq!(consumed, 7);
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> ⓘ
Converts the property to a continuous buffer.
§Returns
A byte vector containing the complete property data.
§Examples
ⓘ
let prop = CorrelationData::new(b"data").unwrap();
let buffer = prop.to_continuous_buffer();
Converts the property to a continuous buffer.
§Returns
A byte vector containing the complete property data.
§Examples
ⓘ
let prop = Property::new(...).unwrap();
let buffer = prop.to_continuous_buffer();
Trait Implementations§
Source§impl Clone for CorrelationData
impl Clone for CorrelationData
Source§fn clone(&self) -> CorrelationData
fn clone(&self) -> CorrelationData
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 CorrelationData
impl Debug for CorrelationData
Source§impl Display for CorrelationData
impl Display for CorrelationData
Source§impl From<CorrelationData> for Property
impl From<CorrelationData> for Property
Source§fn from(v: CorrelationData) -> Self
fn from(v: CorrelationData) -> Self
Converts to this type from the input type.
Source§impl PartialEq for CorrelationData
impl PartialEq for CorrelationData
Source§impl Serialize for CorrelationData
impl Serialize for CorrelationData
impl Eq for CorrelationData
impl StructuralPartialEq for CorrelationData
Auto Trait Implementations§
impl Freeze for CorrelationData
impl RefUnwindSafe for CorrelationData
impl Send for CorrelationData
impl Sync for CorrelationData
impl Unpin for CorrelationData
impl UnwindSafe for CorrelationData
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.