Struct PropertiesBuf
pub struct PropertiesBuf<P: Constraint> {
_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: Constraint> PropertiesBuf<P>
impl<P: Constraint> 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,
PropertiesBufError::DuplicateProperty if a non-repeatable property
with the same identifier was already pushed, or
PropertiesBufError::TooLong if appending would exceed
Constraint::MAX_LEN, or PropertiesBufError::Alloc if the buffer
cannot grow.
pub fn try_extend<'a, I>(&mut self, iter: I) -> Result<(), PropertiesBufError>where
I: IntoIterator<Item = Property<'a>>,
pub fn try_extend<'a, I>(&mut self, iter: I) -> Result<(), PropertiesBufError>where
I: IntoIterator<Item = Property<'a>>,
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, I>(iter: I) -> Result<Self, PropertiesBufError>where
I: IntoIterator<Item = Property<'a>>,
pub fn try_from_iter<'a, I>(iter: I) -> Result<Self, PropertiesBufError>where
I: IntoIterator<Item = Property<'a>>,
Collects properties from an iterator into a new buffer.
§Errors
Returns PropertiesBufError if any property’s identifier is not
in P::ALLOWED, the result would exceed
Constraint::MAX_LEN, or the buffer cannot grow.
fn push_validated( &mut self, seen: &mut IdSet, prop: &Property<'_>, ) -> Result<(), PropertiesBufError>
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: 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.
fn encoded_len_vbi(&self) -> Vbi
pub fn try_to_owned(&self) -> Result<PropertiesBuf<P>, TryReserveError>
pub fn try_to_owned(&self) -> Result<PropertiesBuf<P>, TryReserveError>
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>
impl<P: Constraint> AsRef<Properties<P>> for PropertiesBuf<P>
§fn as_ref(&self) -> &Properties<P>
fn as_ref(&self) -> &Properties<P>
§impl<P: Constraint> Borrow<Properties<P>> for PropertiesBuf<P>
impl<P: Constraint> Borrow<Properties<P>> for PropertiesBuf<P>
§fn borrow(&self) -> &Properties<P>
fn borrow(&self) -> &Properties<P>
§impl<P: Constraint> Clone for PropertiesBuf<P>
impl<P: Constraint> Clone for PropertiesBuf<P>
§impl<P: Constraint> Debug for PropertiesBuf<P>
impl<P: Constraint> Debug for PropertiesBuf<P>
§impl<P: Constraint> Default for PropertiesBuf<P>
impl<P: Constraint> Default for PropertiesBuf<P>
§impl<P: Constraint> Deref for PropertiesBuf<P>
impl<P: Constraint> Deref for PropertiesBuf<P>
§type Target = Properties<P>
type Target = Properties<P>
§fn deref(&self) -> &Properties<P>
fn deref(&self) -> &Properties<P>
impl<P: Constraint> Eq for PropertiesBuf<P>
§impl<P: Constraint> Hash for PropertiesBuf<P>
impl<P: Constraint> Hash for PropertiesBuf<P>
§impl<P: Constraint, Q: Constraint> PartialEq<PropertiesBuf<Q>> for PropertiesBuf<P>
impl<P: Constraint, Q: Constraint> PartialEq<PropertiesBuf<Q>> for PropertiesBuf<P>
§impl<'a, P: Constraint> TryFrom<&[Property<'a>]> for PropertiesBuf<P>
impl<'a, P: Constraint> 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, the encoded properties would
exceed Constraint::MAX_LEN, or the buffer cannot grow.