Skip to main content

Properties

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>

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(super) const fn from_validated(data: &[u8]) -> &Self

Wraps data, which the caller has already validated.

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 fn ids(&self) -> IdSet

Returns the set of property identifiers present.

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>

Decodes properties from the reader.

§Errors

Returns DecodeError if the data is malformed or contains disallowed property IDs.

§

impl Properties<Publish>

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>

pub fn try_to_owned(&self) -> Result<PropertiesBuf<P>, TryReserveError>

Available on crate feature 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.
§

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

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

impl<P: Constraint> 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: Constraint> Debug for Properties<P>

§

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

Formats the value using the given formatter. Read more
§

impl<P: Constraint> Encode for Properties<P>

Encodes the properties section, including its length prefix.

§

fn encode<S: Sink>(&self, w: &mut Writer<S>) -> Result<(), S::Error>

Writes the encoded value. Read more
§

fn encoded_len(&self) -> usize

Returns the number of bytes encode writes.
§

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

§

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

§

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

Feeds this value into the given Hasher. Read more
§

impl<'a, P: Constraint> 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: Constraint, Q: Constraint> PartialEq<Properties<Q>> for Properties<P>

§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
§

impl<P: Constraint> 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

Auto Trait Implementations§

§

impl<P> !Sized for Properties<P>

§

impl<P> Freeze for Properties<P>
where PhantomData<P>: Freeze,

§

impl<P> RefUnwindSafe for Properties<P>

§

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

§

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

§

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

§

impl<P> UnsafeUnpin for Properties<P>

§

impl<P> UnwindSafe for Properties<P>

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