Skip to main content

ProtoDecoderRegistry

Struct ProtoDecoderRegistry 

Source
pub struct ProtoDecoderRegistry { /* private fields */ }
Available on crate feature proto only.
Expand description

A store of extension decoders, keyed by the trait they produce and the name the encoder wrote on the wire.

A session carries one registry, as a SessionConfig extension. Every library that ships extension types adds its decoders to that registry with SessionConfig::update_extension, which creates the registry if there is none:

ⓘ
// in each library
pub fn register(config: &mut SessionConfig) -> Result<()> {
    config.update_extension(MyExec::register_proto)?;
    config.update_extension(MyExpr::register_proto)
}

// in the application that owns the session
let mut config = SessionConfig::new();
lib_one::register(&mut config)?;
lib_two::register(&mut config)?;

Do not attach a registry with SessionConfig::with_extension: it replaces the registry, so it discards the decoders that other libraries added.

The libraries need to know nothing about each other, and the order they are called in does not matter: lookup is by name, and a real collision is an error from register_decoder.

Callers normally reach this type through a kind’s typed facade rather than through the methods here.

Implementations§

Source§

impl ProtoDecoderRegistry

Source

pub fn new() -> ProtoDecoderRegistry

Create an empty registry.

Source

pub fn register_decoder<Kind, T, D>( &mut self, name: &str, decoder: D, ) -> Result<(), DataFusionError>
where Kind: 'static + ?Sized, T: 'static + ?Sized, D: Any + Send + Sync,

Register decoder under name, for extensions dispatched as Kind.

Kind is the trait object the decoder produces, such as dyn ExecutionPlan. T is the concrete type being registered; it is used only for identity, so that registering the same type twice is a no-op while a different type under a taken name is an error. D is the decoder itself, whose type the matching decoder call must name exactly.

Source

pub fn decoder<Kind, D>(&self, name: &str) -> Option<&D>
where Kind: 'static + ?Sized, D: Any + Send + Sync,

The decoder registered under name for extensions dispatched as Kind.

D must be the same type the matching register_decoder call supplied. A different D reads as “not registered” rather than as an error, because the two calls are always made by the same facade.

Source

pub fn names<Kind>(&self) -> impl Iterator<Item = &str>
where Kind: 'static + ?Sized,

Every name registered for Kind, in arbitrary order.

Trait Implementations§

Source§

impl Clone for ProtoDecoderRegistry

Source§

fn clone(&self) -> ProtoDecoderRegistry

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 ProtoDecoderRegistry

Source§

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

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

impl Default for ProtoDecoderRegistry

Source§

fn default() -> ProtoDecoderRegistry

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

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.