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
impl ExtensionRegistry
Sourcefn register<T>(
&mut self,
ext_type: ExtensionType,
) -> Result<(), RegistrationError>where
T: Extension,
fn register<T>(
&mut self,
ext_type: ExtensionType,
) -> Result<(), RegistrationError>where
T: Extension,
Register an extension type with a specific ExtensionType
Sourcepub fn register_relation<T>(&mut self) -> Result<(), RegistrationError>where
T: Extension,
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().
Sourcepub fn register_enhancement<T>(&mut self) -> Result<(), RegistrationError>where
T: Extension,
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().
Sourcepub fn register_optimization<T>(&mut self) -> Result<(), RegistrationError>where
T: Extension,
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().
Sourcepub fn parse_extension(
&self,
extension_name: &str,
args: &ExtensionArgs,
) -> Result<Any, ExtensionError>
pub fn parse_extension( &self, extension_name: &str, args: &ExtensionArgs, ) -> Result<Any, ExtensionError>
Parse extension arguments into a protobuf Any message
Sourcepub fn parse_enhancement(
&self,
enhancement_name: &str,
args: &ExtensionArgs,
) -> Result<Any, ExtensionError>
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.
Sourcepub fn parse_optimization(
&self,
optimization_name: &str,
args: &ExtensionArgs,
) -> Result<Any, ExtensionError>
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.
Sourcefn parse_with_type(
&self,
ext_type: ExtensionType,
name: &str,
args: &ExtensionArgs,
) -> Result<Any, ExtensionError>
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
Sourcepub fn decode(
&self,
detail: AnyRef<'_>,
) -> Result<(String, ExtensionArgs), ExtensionError>
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
Sourcepub fn decode_enhancement(
&self,
detail: AnyRef<'_>,
) -> Result<(String, ExtensionArgs), ExtensionError>
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.
Sourcepub fn decode_optimization(
&self,
detail: AnyRef<'_>,
) -> Result<(String, ExtensionArgs), ExtensionError>
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.
Sourcefn decode_with_type(
&self,
ext_type: ExtensionType,
detail: AnyRef<'_>,
) -> Result<(String, ExtensionArgs), ExtensionError>
fn decode_with_type( &self, ext_type: ExtensionType, detail: AnyRef<'_>, ) -> Result<(String, ExtensionArgs), ExtensionError>
Internal method to decode extension detail with a specific ExtensionType
Sourcepub fn extension_names(&self, ext_type: ExtensionType) -> Vec<&str>
pub fn extension_names(&self, ext_type: ExtensionType) -> Vec<&str>
Get all registered extension names for a specific ExtensionType
Sourcepub fn has_extension(&self, ext_type: ExtensionType, name: &str) -> bool
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
impl Clone for ExtensionRegistry
Source§fn clone(&self) -> ExtensionRegistry
fn clone(&self) -> ExtensionRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more