Properties

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>

pub const EMPTY: &'static Self

An empty properties section.

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

Creates from raw property bytes WITHOUT validation.

§Safety

The caller must guarantee that:

  1. data contains only structurally valid property bytes;
  2. every property ID in data is in P::ALLOWED;
  3. the length of data does not exceed Vbi::MAX_USIZE.

pub const fn is_empty(&self) -> bool

Returns true if there are no properties.

pub const fn as_bytes(&self) -> &[u8]

Returns the raw bytes of the properties section.

pub const fn iter(&self) -> PropertiesIter<'_>

Returns an iterator over the properties in this section.

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

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

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>

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>

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.
§

fn as_ref(&self) -> &Properties<P>

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<P: PropertyConstraint> Borrow<Properties<P>> for PropertiesBuf<P>

Available on crate feature alloc only.
§

fn borrow(&self) -> &Properties<P>

Immutably borrows from an owned value. Read more
§

impl<P: PropertyConstraint> Debug for Properties<P>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<P: PropertyConstraint> Hash for Properties<P>

§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
§

impl<'a, P: PropertyConstraint> IntoIterator for &'a Properties<P>

§

type Item = Property<'a>

The type of the elements being iterated over.
§

type IntoIter = PropertiesIter<'a>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
§

impl<P: PropertyConstraint, Q: PropertyConstraint> PartialEq<Properties<Q>> for Properties<P>

§

fn eq(&self, other: &Properties<Q>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<P: PropertyConstraint> ToOwned for Properties<P>

Available on crate feature alloc only.
§

type Owned = PropertiesBuf<P>

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<P: PropertyConstraint> Eq for Properties<P>

Auto Trait Implementations§

§

impl<P> Freeze for Properties<P>

§

impl<P> RefUnwindSafe for Properties<P>
where P: RefUnwindSafe,

§

impl<P> Send for Properties<P>
where P: Send,

§

impl<P> !Sized for Properties<P>

§

impl<P> Sync for Properties<P>
where P: Sync,

§

impl<P> Unpin for Properties<P>
where P: Unpin,

§

impl<P> UnwindSafe for Properties<P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more