ExtensionRegistry

Struct ExtensionRegistry 

Source
pub struct ExtensionRegistry {
    handlers: HashMap<(ExtensionType, String), Arc<dyn ExtensionConverter>>,
    type_urls: HashMap<(ExtensionType, String), String>,
}
Expand description

Registry for extension handlers

Fields§

§handlers: HashMap<(ExtensionType, String), Arc<dyn ExtensionConverter>>§type_urls: HashMap<(ExtensionType, String), String>

Implementations§

Source§

impl ExtensionRegistry

Source

pub fn new() -> Self

Create a new empty extension registry

Source

fn register<T>( &mut self, ext_type: ExtensionType, ) -> Result<(), RegistrationError>
where T: Extension,

Register an extension type with a specific ExtensionType

Source

pub fn register_relation<T>(&mut self) -> Result<(), RegistrationError>
where T: Extension,

Register a relation extension type that implements both AnyConvertible and Explainable

The canonical textual name comes from T::name().

Source

pub fn register_enhancement<T>(&mut self) -> Result<(), RegistrationError>
where T: Extension,

Register an enhancement type that implements both AnyConvertible and Explainable

Enhancements are registered in a separate namespace from relation extensions, allowing the same type URL to exist in both namespaces without conflict.

The canonical textual name comes from T::name().

Source

pub fn register_optimization<T>(&mut self) -> Result<(), RegistrationError>
where T: Extension,

Register an optimization type that implements both AnyConvertible and Explainable

Optimizations are registered in a separate namespace from relation extensions, allowing the same type URL to exist in both namespaces without conflict.

The canonical textual name comes from T::name().

Source

pub fn parse_extension( &self, extension_name: &str, args: &ExtensionArgs, ) -> Result<Any, ExtensionError>

Parse extension arguments into a protobuf Any message

Source

pub fn parse_enhancement( &self, enhancement_name: &str, args: &ExtensionArgs, ) -> Result<Any, ExtensionError>

Parse enhancement arguments into a protobuf Any message

Looks up the enhancement handler in the enhancement namespace and parses the arguments into a protobuf Any message.

Source

pub fn parse_optimization( &self, optimization_name: &str, args: &ExtensionArgs, ) -> Result<Any, ExtensionError>

Parse optimization arguments into a protobuf Any message

Looks up the optimization handler in the optimization namespace and parses the arguments into a protobuf Any message.

Source

fn parse_with_type( &self, ext_type: ExtensionType, name: &str, args: &ExtensionArgs, ) -> Result<Any, ExtensionError>

Internal method to parse extension arguments with a specific ExtensionType

Source

pub fn decode( &self, detail: AnyRef<'_>, ) -> Result<(String, ExtensionArgs), ExtensionError>

Decode extension detail to extension name and ExtensionArgs This is the primary method for textification - given an AnyRef with extension detail, decode it to the extension name and appropriate ExtensionArgs for display

Source

pub fn decode_enhancement( &self, detail: AnyRef<'_>, ) -> Result<(String, ExtensionArgs), ExtensionError>

Decode enhancement detail to enhancement name and ExtensionArgs

This is the primary method for textification of enhancements - given an AnyRef with enhancement detail, decode it to the enhancement name and appropriate ExtensionArgs for display.

Looks up the enhancement handler in the enhancement namespace by type URL.

Source

pub fn decode_optimization( &self, detail: AnyRef<'_>, ) -> Result<(String, ExtensionArgs), ExtensionError>

Decode optimization detail to optimization name and ExtensionArgs

This is the primary method for textification of optimizations - given an AnyRef with optimization detail, decode it to the optimization name and appropriate ExtensionArgs for display.

Looks up the optimization handler in the optimization namespace by type URL.

Source

fn decode_with_type( &self, ext_type: ExtensionType, detail: AnyRef<'_>, ) -> Result<(String, ExtensionArgs), ExtensionError>

Internal method to decode extension detail with a specific ExtensionType

Source

pub fn extension_names(&self, ext_type: ExtensionType) -> Vec<&str>

Get all registered extension names for a specific ExtensionType

Source

pub fn has_extension(&self, ext_type: ExtensionType, name: &str) -> bool

Check if an extension is registered for a specific ExtensionType

Trait Implementations§

Source§

impl Clone for ExtensionRegistry

Source§

fn clone(&self) -> ExtensionRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtensionRegistry

Source§

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

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

impl Default for ExtensionRegistry

Source§

fn default() -> ExtensionRegistry

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> 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 = 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.