Struct Properties
#[repr(transparent)]pub struct Properties<P: Constraint> {
_marker: PhantomData<P>,
bytes: [u8],
}Expand description
A borrowed view over a properties section.
The type is parameterised over a Constraint marker that
determines the permitted property IDs.
This is an unsized type like [u8]. Use &Properties for borrowed
references and PropertiesBuf for owned
values (requires alloc).
Use the type aliases AnyProperties,
ConnectProperties, etc. rather than spelling
the generic out by hand.
Fields§
§_marker: PhantomData<P>§bytes: [u8]Implementations§
§impl<P: Constraint> Properties<P>
impl<P: Constraint> Properties<P>
pub const EMPTY: &'static Self
pub const EMPTY: &'static Self
An empty properties section.
pub const fn new(data: &[u8]) -> Result<&Self, DecodeError>
pub const fn new(data: &[u8]) -> Result<&Self, DecodeError>
Creates from raw property bytes, validating that every property can be
decoded successfully and is permitted by P.
§Errors
Returns wire::DecodeError if any property in data is malformed
or has a property identifier not in
P::ALLOWED.
pub(super) const fn from_validated(data: &[u8]) -> &Self
pub(super) const fn from_validated(data: &[u8]) -> &Self
Wraps data, which the caller has already validated.
pub const fn iter(&self) -> PropertiesIter<'_> ⓘ
pub const fn iter(&self) -> PropertiesIter<'_> ⓘ
Returns an iterator over the properties in this section.
pub fn find(&self, id: Id) -> Option<Property<'_>>
pub fn find(&self, id: Id) -> Option<Property<'_>>
Finds the first occurrence of a property by identifier.
This is a linear scan over all properties.
const fn encoded_len_vbi(&self) -> Vbi
pub const fn decode<'a>(r: &mut Reader<'a>) -> Result<&'a Self, DecodeError>
pub const fn decode<'a>(r: &mut Reader<'a>) -> Result<&'a Self, DecodeError>
Decodes properties from the reader.
§Errors
Returns DecodeError if the data is malformed or
contains disallowed property IDs.
§impl Properties<Publish>
impl Properties<Publish>
pub(crate) const fn section_len(&self, with_topic_alias: bool) -> Vbi
pub(crate) const fn section_len(&self, with_topic_alias: bool) -> Vbi
Returns the length prefix of the PUBLISH properties section, with or without an appended Topic Alias property.
§impl<P: Constraint> Properties<P>
impl<P: Constraint> Properties<P>
pub fn try_to_owned(&self) -> Result<PropertiesBuf<P>, TryReserveError>
Available on crate feature alloc only.
pub fn try_to_owned(&self) -> Result<PropertiesBuf<P>, TryReserveError>
alloc only.Copies the properties into a PropertiesBuf without panicking if the
allocation fails.
§Errors
Returns TryReserveError if the allocation fails.
Trait Implementations§
§impl<P: Constraint> AsRef<Properties<P>> for PropertiesBuf<P>
Available on crate feature alloc only.
impl<P: Constraint> AsRef<Properties<P>> for PropertiesBuf<P>
alloc only.§fn as_ref(&self) -> &Properties<P>
fn as_ref(&self) -> &Properties<P>
§impl<P: Constraint> Borrow<Properties<P>> for PropertiesBuf<P>
Available on crate feature alloc only.
impl<P: Constraint> Borrow<Properties<P>> for PropertiesBuf<P>
alloc only.§fn borrow(&self) -> &Properties<P>
fn borrow(&self) -> &Properties<P>
§impl<P: Constraint> Debug for Properties<P>
impl<P: Constraint> Debug for Properties<P>
§impl<P: Constraint> Encode for Properties<P>
Encodes the properties section, including its length prefix.
impl<P: Constraint> Encode for Properties<P>
Encodes the properties section, including its length prefix.
impl<P: Constraint> Eq for Properties<P>
§impl<P: Constraint> Hash for Properties<P>
impl<P: Constraint> Hash for Properties<P>
§impl<'a, P: Constraint> IntoIterator for &'a Properties<P>
impl<'a, P: Constraint> IntoIterator for &'a Properties<P>
§impl<P: Constraint, Q: Constraint> PartialEq<Properties<Q>> for Properties<P>
impl<P: Constraint, Q: Constraint> PartialEq<Properties<Q>> for Properties<P>
§impl<P: Constraint> ToOwned for Properties<P>
Available on crate feature alloc only.
impl<P: Constraint> ToOwned for Properties<P>
alloc only.