Skip to main content

TypeMap

Struct TypeMap 

Source
pub struct TypeMap<Src: WireSource, S, B> { /* private fields */ }
Expand description

Generic type-to-decoder registry.

Keyed by Src::TypeKey (the wire’s native type identity: Oid for pg_walstream, Arc<str> for wal2json and maxwell). Implements WireAdapter via a single HashMap::get per column.

Implementations§

Source§

impl<Src: WireSource, S, B> TypeMap<Src, S, B>

Source

pub fn new() -> Self

Empty registry.

Source

pub fn register<D>(&mut self, key: Src::TypeKey, decoder: D) -> &mut Self
where D: Decoder<Src, S, B> + Send + Sync + 'static,

Register (or replace) the decoder for key. Returns &mut self for chaining.

Source

pub fn with<D>(self, key: Src::TypeKey, decoder: D) -> Self
where D: Decoder<Src, S, B> + Send + Sync + 'static,

Same as register but consumes self for builder-style chaining: TypeMap::new().with(k1, d1).with(k2, d2).

Source

pub fn len(&self) -> usize

Number of registered entries.

Source

pub fn is_empty(&self) -> bool

True when the registry has zero entries.

Source§

impl<Src, S, B> TypeMap<Src, S, B>
where Src: TypeMapDefaults<S, B>,

Source

pub fn defaults() -> Self

Pre-populated registry with every self-evident mapping the crate ships for this source, sugared for <Src as TypeMapDefaults<S, B>>::defaults().

Trait Implementations§

Source§

impl<Src: WireSource, S, B> Default for TypeMap<Src, S, B>

Source§

fn default() -> Self

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

impl<Src: WireSource, S, B> WireAdapter<Src, S, B> for TypeMap<Src, S, B>

Source§

fn decode(&self, payload: Src::Payload<'_>) -> Result<Value<S, B>, DecodeError>

Decode one column payload. Read more

Auto Trait Implementations§

§

impl<Src, S, B> !RefUnwindSafe for TypeMap<Src, S, B>

§

impl<Src, S, B> !UnwindSafe for TypeMap<Src, S, B>

§

impl<Src, S, B> Freeze for TypeMap<Src, S, B>

§

impl<Src, S, B> Send for TypeMap<Src, S, B>
where <Src as WireSource>::TypeKey: Send,

§

impl<Src, S, B> Sync for TypeMap<Src, S, B>
where <Src as WireSource>::TypeKey: Sync,

§

impl<Src, S, B> Unpin for TypeMap<Src, S, B>
where <Src as WireSource>::TypeKey: Unpin,

§

impl<Src, S, B> UnsafeUnpin for TypeMap<Src, S, B>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.