Skip to main content

Codecs

Struct Codecs 

Source
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

Source

pub fn new() -> Self

The built-in codecs: JSON (json::codec).

Source

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.

Source

pub fn get(&self, name: &str) -> Option<&Codec>

The codec registered as name.

Source

pub fn names(&self) -> impl Iterator<Item = &str>

The names of the registered codecs, in the order they were first registered.

Source

pub fn by_media_type(&self, content_type: &str) -> Option<&Codec>

The codec a content-type names (case and parameters ignored).

Source

pub fn decode_snapshot(&self, record: &[u8]) -> Result<Value, Error>

Decodes a snapshot record written by any registered codec, found by its format byte.

Trait Implementations§

Source§

impl Clone for Codecs

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Codecs

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Codecs

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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
where RawVecInner: Send, Arc<dyn EventCodec>: Send, Arc<dyn SnapshotCodec>: Send,

§

impl Sync for Codecs
where RawVecInner: Sync, Arc<dyn EventCodec>: Sync, Arc<dyn SnapshotCodec>: Sync,

§

impl Unpin for Codecs
where *const u8 is !null: Unpin, Arc<dyn EventCodec>: Unpin, Arc<dyn SnapshotCodec>: Unpin,

§

impl UnsafeUnpin for Codecs

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.