pub struct MediaPayloadMetadataCollection { /* private fields */ }
Expand description
Allows storing arbitrary attributes and value pairs that can are relevant to an individual media payload/packet. These are stored in a relatively efficient way to make it cheap to clone and attempt to minimize per-packet heap allocations. Once a metadata collection has been created it cannot be modified.
The metadata currently relies on being passed in a BytesMut
buffer that it will use for
storage. This allows for the creator of media payloads to maintain an arena style memory
buffer that persists across media payloads, which should eventually cause each media payload
to no longer require its own heap allocation and efficiently re-use unreserved parts of the
memory buffer.
The trade off for cloning and allocation efficiency is that iterating through metadata is an O(N) operation, which means if you need to look for a specific type of metadata you may have to iterate through all other metadata items first. This tradeoff was deemed acceptable for now with the idea that each payload would only have a small amount of metadata attached to it.
Implementations
sourceimpl MediaPayloadMetadataCollection
impl MediaPayloadMetadataCollection
sourcepub fn new(
entries: impl Iterator<Item = MetadataEntry>,
buffer: &mut BytesMut
) -> Self
pub fn new(
entries: impl Iterator<Item = MetadataEntry>,
buffer: &mut BytesMut
) -> Self
Creates a new collection of metadata based on the provided entries. A buffer is passed in which can allow the creators of the collection to maintain an arena to reduce allocations for each new metadata collection that is created.
sourcepub fn iter(&self) -> impl Iterator<Item = MetadataEntry>
pub fn iter(&self) -> impl Iterator<Item = MetadataEntry>
Provides a non-consuming iterator that allows reading of entries within the collection
Trait Implementations
sourceimpl Clone for MediaPayloadMetadataCollection
impl Clone for MediaPayloadMetadataCollection
sourcefn clone(&self) -> MediaPayloadMetadataCollection
fn clone(&self) -> MediaPayloadMetadataCollection
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl PartialEq<MediaPayloadMetadataCollection> for MediaPayloadMetadataCollection
impl PartialEq<MediaPayloadMetadataCollection> for MediaPayloadMetadataCollection
sourcefn eq(&self, other: &MediaPayloadMetadataCollection) -> bool
fn eq(&self, other: &MediaPayloadMetadataCollection) -> bool
impl Eq for MediaPayloadMetadataCollection
impl StructuralEq for MediaPayloadMetadataCollection
impl StructuralPartialEq for MediaPayloadMetadataCollection
Auto Trait Implementations
impl RefUnwindSafe for MediaPayloadMetadataCollection
impl Send for MediaPayloadMetadataCollection
impl Sync for MediaPayloadMetadataCollection
impl Unpin for MediaPayloadMetadataCollection
impl UnwindSafe for MediaPayloadMetadataCollection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresourceimpl<T> DowncastSync for Twhere
T: Any + Send + Sync,
impl<T> DowncastSync for Twhere
T: Any + Send + Sync,
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.