Struct PropertiesBuf
pub struct PropertiesBuf<P: PropertyConstraint> {
_marker: PhantomData<P>,
bytes: Vec<u8>,
}alloc only.Expand description
Owned property bytes, the owned counterpart to Properties<P>.
Fields§
§_marker: PhantomData<P>§bytes: Vec<u8>Implementations§
§impl<P: PropertyConstraint> PropertiesBuf<P>
impl<P: PropertyConstraint> PropertiesBuf<P>
pub const fn new() -> Self
pub const fn new() -> Self
Creates an empty property buffer.
pub const fn as_properties(&self) -> &Properties<P>
pub const fn as_properties(&self) -> &Properties<P>
Returns a reference to the underlying Properties<P>.
pub fn push(&mut self, prop: Property<'_>) -> Result<(), PropertiesBufError>
pub fn push(&mut self, prop: Property<'_>) -> Result<(), PropertiesBufError>
Appends a property to the buffer.
§Errors
Returns PropertiesBufError::DisallowedProperty if the property’s
identifier is not in P::ALLOWED, or
PropertiesBufError::TooLong if appending would exceed
Vbi::MAX.
pub fn try_extend<'a>(
&mut self,
iter: impl IntoIterator<Item = Property<'a>>,
) -> Result<(), PropertiesBufError>
pub fn try_extend<'a>( &mut self, iter: impl IntoIterator<Item = Property<'a>>, ) -> Result<(), PropertiesBufError>
Extends this buffer with all properties from an iterator.
§Errors
Returns PropertiesBufError on the first disallowed or
over-length property. Properties pushed before the error remain.
pub fn try_from_iter<'a>(
iter: impl IntoIterator<Item = Property<'a>>,
) -> Result<Self, PropertiesBufError>
pub fn try_from_iter<'a>( iter: impl IntoIterator<Item = Property<'a>>, ) -> Result<Self, PropertiesBufError>
Collects properties from an iterator into a new buffer.
§Errors
Returns PropertiesBufError if any property’s identifier is not
in P::ALLOWED or the result would
exceed Vbi::MAX.
Methods from Deref<Target = Properties<P>>§
pub const EMPTY: &'static Self
pub fn iter(&self) -> PropertiesIter<'_> ⓘ
pub fn iter(&self) -> PropertiesIter<'_> ⓘ
Returns an iterator over the properties in this section.
pub fn find(&self, id: PropertyId) -> Option<Property<'_>>
pub 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 fn collect_ids(&self) -> PropertyIdSet
pub 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.
fn len_vbi(&self) -> Vbi
pub fn encoded_len(&self) -> usize
pub 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 fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
pub 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.
Trait Implementations§
§impl<P: PropertyConstraint> AsRef<Properties<P>> for PropertiesBuf<P>
impl<P: PropertyConstraint> AsRef<Properties<P>> for PropertiesBuf<P>
§fn as_ref(&self) -> &Properties<P>
fn as_ref(&self) -> &Properties<P>
§impl<P: PropertyConstraint> Borrow<Properties<P>> for PropertiesBuf<P>
impl<P: PropertyConstraint> Borrow<Properties<P>> for PropertiesBuf<P>
§fn borrow(&self) -> &Properties<P>
fn borrow(&self) -> &Properties<P>
§impl<P: PropertyConstraint> Clone for PropertiesBuf<P>
impl<P: PropertyConstraint> Clone for PropertiesBuf<P>
§impl<P: PropertyConstraint> Debug for PropertiesBuf<P>
impl<P: PropertyConstraint> Debug for PropertiesBuf<P>
§impl<P: PropertyConstraint> Default for PropertiesBuf<P>
impl<P: PropertyConstraint> Default for PropertiesBuf<P>
§impl<P: PropertyConstraint> Deref for PropertiesBuf<P>
impl<P: PropertyConstraint> Deref for PropertiesBuf<P>
§type Target = Properties<P>
type Target = Properties<P>
§fn deref(&self) -> &Properties<P>
fn deref(&self) -> &Properties<P>
§impl<P: PropertyConstraint> Hash for PropertiesBuf<P>
impl<P: PropertyConstraint> Hash for PropertiesBuf<P>
§impl<P: PropertyConstraint, Q: PropertyConstraint> PartialEq<PropertiesBuf<Q>> for PropertiesBuf<P>
impl<P: PropertyConstraint, Q: PropertyConstraint> PartialEq<PropertiesBuf<Q>> for PropertiesBuf<P>
§impl<'a, P: PropertyConstraint> TryFrom<&[Option<Property<'a>>]> for PropertiesBuf<P>
impl<'a, P: PropertyConstraint> TryFrom<&[Option<Property<'a>>]> for PropertiesBuf<P>
§fn try_from(value: &[Option<Property<'a>>]) -> Result<Self, Self::Error>
fn try_from(value: &[Option<Property<'a>>]) -> Result<Self, Self::Error>
Builds a PropertiesBuf from a slice of optional properties,
skipping Nones.
§Errors
Returns PropertiesBufError if any present property’s identifier
is not in P::ALLOWED, or if the
encoded properties would exceed Vbi::MAX.
§type Error = PropertiesBufError
type Error = PropertiesBufError
§impl<'a, P: PropertyConstraint> TryFrom<&[Property<'a>]> for PropertiesBuf<P>
impl<'a, P: PropertyConstraint> TryFrom<&[Property<'a>]> for PropertiesBuf<P>
§fn try_from(value: &[Property<'a>]) -> Result<Self, Self::Error>
fn try_from(value: &[Property<'a>]) -> Result<Self, Self::Error>
Builds a PropertiesBuf from a slice of properties.
§Errors
Returns PropertiesBufError if any property’s identifier is not in
P::ALLOWED, or if the encoded
properties would exceed Vbi::MAX.