pub struct Codecs { /* private fields */ }Expand description
The codecs a host reads and writes records with, by name, with JSON always among them. Media types and snapshot format bytes each belong to one codec, so an event record’s content type and a snapshot record’s first byte find the codec that reads it.
Implementations§
Source§impl Codecs
impl Codecs
Sourcepub fn new() -> Self
pub fn new() -> Self
The built-in codecs: JSON (json::codec).
Sourcepub fn register(&mut self, codec: Codec) -> Result<&mut Self, Error>
pub fn register(&mut self, codec: Codec) -> Result<&mut Self, Error>
Registers a codec, replacing the one of the same name if there is one. Fails when another codec has one of its media types or its snapshot format byte.
Sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
The names of the registered codecs, in the order they were first registered.
Sourcepub fn by_media_type(&self, content_type: &str) -> Option<&Codec>
pub fn by_media_type(&self, content_type: &str) -> Option<&Codec>
The codec a content-type names (case and parameters ignored).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Codecs
impl !UnwindSafe for Codecs
impl Forget for Codecs
impl Freeze for Codecs
impl Move for Codecs
impl Send for Codecs
impl Sync for Codecs
impl Unpin for Codecs
impl UnsafeUnpin for Codecs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more