Struct Properties
#[repr(transparent)]pub struct Properties<P: PropertyConstraint> {
_marker: PhantomData<P>,
bytes: [u8],
}Expand description
A borrowed view over a properties section.
The type is parameterised over a PropertyConstraint 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: PropertyConstraint> Properties<P>
impl<P: PropertyConstraint> 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 const unsafe fn new_unchecked(data: &[u8]) -> &Self
pub const unsafe fn new_unchecked(data: &[u8]) -> &Self
Creates from raw property bytes WITHOUT validation.
§Safety
The caller must guarantee that:
datacontains only structurally valid property bytes;- every property ID in
datais inP::ALLOWED; - the length of
datadoes not exceedVbi::MAX_USIZE.
pub const fn iter(&self) -> PropertiesIter<'_> ⓘ
pub const fn iter(&self) -> PropertiesIter<'_> ⓘ
Returns an iterator over the properties in this section.
pub const fn find(&self, id: PropertyId) -> Option<Property<'_>>
pub const fn find(&self, id: PropertyId) -> Option<Property<'_>>
Find the first occurrence of a property by identifier.
This is a linear scan over all properties.
pub const fn collect_ids(&self) -> PropertyIdSet
pub const fn collect_ids(&self) -> PropertyIdSet
Collects the set of property ids present in this section.
The word “collect” is used to indicate that this is a linear scan over all properties.
const fn len_vbi(&self) -> Vbi
pub const fn encoded_len(&self) -> usize
pub const fn encoded_len(&self) -> usize
Returns the number of bytes needed to encode this properties section including the leading variable byte integer length prefix.
pub const fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
pub const fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
Encodes this properties section into the writer, including the leading variable byte integer length prefix.
§Errors
Returns EncodeError if the writer does not have
enough capacity.
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.
Trait Implementations§
§impl<P: PropertyConstraint> AsRef<Properties<P>> for PropertiesBuf<P>
Available on crate feature alloc only.
impl<P: PropertyConstraint> AsRef<Properties<P>> for PropertiesBuf<P>
alloc only.§fn as_ref(&self) -> &Properties<P>
fn as_ref(&self) -> &Properties<P>
§impl<P: PropertyConstraint> Borrow<Properties<P>> for PropertiesBuf<P>
Available on crate feature alloc only.
impl<P: PropertyConstraint> Borrow<Properties<P>> for PropertiesBuf<P>
alloc only.§fn borrow(&self) -> &Properties<P>
fn borrow(&self) -> &Properties<P>
§impl<P: PropertyConstraint> Debug for Properties<P>
impl<P: PropertyConstraint> Debug for Properties<P>
§impl<P: PropertyConstraint> Hash for Properties<P>
impl<P: PropertyConstraint> Hash for Properties<P>
§impl<'a, P: PropertyConstraint> IntoIterator for &'a Properties<P>
impl<'a, P: PropertyConstraint> IntoIterator for &'a Properties<P>
§impl<P: PropertyConstraint, Q: PropertyConstraint> PartialEq<Properties<Q>> for Properties<P>
impl<P: PropertyConstraint, Q: PropertyConstraint> PartialEq<Properties<Q>> for Properties<P>
§impl<P: PropertyConstraint> ToOwned for Properties<P>
Available on crate feature alloc only.
impl<P: PropertyConstraint> ToOwned for Properties<P>
alloc only.