pub struct ExtensionRegistry { /* private fields */ }Expand description
Extension Registries store extensions to be looked up e.g. during validation.
Implementations§
Source§impl ExtensionRegistry
 
impl ExtensionRegistry
Sourcepub fn new_with_extension_resolution(
    extensions: impl IntoIterator<Item = Extension>,
    other_extensions: &WeakExtensionRegistry,
) -> Result<ExtensionRegistry, ExtensionResolutionError>
 
pub fn new_with_extension_resolution( extensions: impl IntoIterator<Item = Extension>, other_extensions: &WeakExtensionRegistry, ) -> Result<ExtensionRegistry, ExtensionResolutionError>
Given a list of extensions that has been deserialized, create a new
registry while updating any internal Weak<Extension> reference to
point to the newly created Arcs in the registry.
§Errors
- If an opaque operation cannot be resolved to an extension operation.
- If an extension operation references an extension that is missing from the registry.
- If a custom type references an extension that is missing from the registry.
Source§impl ExtensionRegistry
 
impl ExtensionRegistry
Sourcepub fn new(extensions: impl IntoIterator<Item = Arc<Extension>>) -> Self
 
pub fn new(extensions: impl IntoIterator<Item = Arc<Extension>>) -> Self
Create a new empty extension registry.
Sourcepub fn load_json(
    reader: impl Read,
    other_extensions: &ExtensionRegistry,
) -> Result<Self, ExtensionRegistryLoadError>
 
pub fn load_json( reader: impl Read, other_extensions: &ExtensionRegistry, ) -> Result<Self, ExtensionRegistryLoadError>
Load an ExtensionRegistry serialized as json.
After deserialization, updates all the internal Weak<Extension>
references to point to the newly created Arcs in the registry,
or extensions in the additional_extensions parameter.
Sourcepub fn get(&self, name: &str) -> Option<&Arc<Extension>>
 
pub fn get(&self, name: &str) -> Option<&Arc<Extension>>
Gets the Extension with the given name
Sourcepub fn contains(&self, name: &str) -> bool
 
pub fn contains(&self, name: &str) -> bool
Returns true if the registry contains an extension with the given name.
Sourcepub fn validate(&self) -> Result<(), ExtensionRegistryError>
 
pub fn validate(&self) -> Result<(), ExtensionRegistryError>
Validate the set of extensions.
Sourcepub fn register(
    &mut self,
    extension: impl Into<Arc<Extension>>,
) -> Result<(), ExtensionRegistryError>
 
pub fn register( &mut self, extension: impl Into<Arc<Extension>>, ) -> Result<(), ExtensionRegistryError>
Registers a new extension to the registry.
Returns a reference to the registered extension if successful.
Sourcepub fn register_updated(&mut self, extension: impl Into<Arc<Extension>>)
 
pub fn register_updated(&mut self, extension: impl Into<Arc<Extension>>)
Registers a new extension to the registry, keeping the one most up to date if the extension already exists.
If extension IDs match, the extension with the higher version is kept. If versions match, the original extension is kept. Returns a reference to the registered extension if successful.
Takes an Arc to the extension. To avoid cloning Arcs unless necessary,
see ExtensionRegistry::register_updated_ref.
Sourcepub fn register_updated_ref(&mut self, extension: &Arc<Extension>)
 
pub fn register_updated_ref(&mut self, extension: &Arc<Extension>)
Registers a new extension to the registry, keeping the one most up to date if the extension already exists.
If extension IDs match, the extension with the higher version is kept. If versions match, the original extension is kept. Returns a reference to the registered extension if successful.
Clones the Arc only when required. For no-cloning version see
ExtensionRegistry::register_updated.
Sourcepub fn iter(&self) -> <&Self as IntoIterator>::IntoIter
 
pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter
Returns an iterator over the extensions in the registry.
Sourcepub fn ids(&self) -> impl Iterator<Item = &ExtensionId>
 
pub fn ids(&self) -> impl Iterator<Item = &ExtensionId>
Returns an iterator over the extensions ids in the registry.
Sourcepub fn remove_extension(&mut self, name: &ExtensionId) -> Option<Arc<Extension>>
 
pub fn remove_extension(&mut self, name: &ExtensionId) -> Option<Arc<Extension>>
Delete an extension from the registry and return it if it was present.
Sourcepub fn new_cyclic<F, E>(
    extensions: impl IntoIterator<Item = Extension>,
    init: F,
) -> Result<Self, E>
 
pub fn new_cyclic<F, E>( extensions: impl IntoIterator<Item = Extension>, init: F, ) -> Result<Self, E>
Constructs a new ExtensionRegistry from a list of Extensions while
giving you a WeakExtensionRegistry to the allocation. This allows
you to add Weak self-references to the Extensions while
constructing them, before wrapping them in Arcs.
This is similar to Arc::new_cyclic, but for ExtensionRegistries.
Calling Weak::upgrade on a weak reference in the
WeakExtensionRegistry inside your closure will return an extension
with no internal (op / type / value) definitions.
Trait Implementations§
Source§impl Clone for ExtensionRegistry
 
impl Clone for ExtensionRegistry
Source§impl Debug for ExtensionRegistry
 
impl Debug for ExtensionRegistry
Source§impl Default for ExtensionRegistry
 
impl Default for ExtensionRegistry
Source§fn default() -> ExtensionRegistry
 
fn default() -> ExtensionRegistry
Source§impl<'de> Deserialize<'de> for ExtensionRegistry
Encode/decode ExtensionRegistry as a list of extensions.
 
impl<'de> Deserialize<'de> for ExtensionRegistry
Encode/decode ExtensionRegistry as a list of extensions.
Any Weak<Extension> references inside the registry will be left unresolved.
Prefer using ExtensionRegistry::load_json when deserializing.
Source§fn deserialize<D>(deserializer: D) -> Result<ExtensionRegistry, D::Error>where
    D: Deserializer<'de>,
 
fn deserialize<D>(deserializer: D) -> Result<ExtensionRegistry, D::Error>where
    D: Deserializer<'de>,
Source§impl Display for ExtensionRegistry
 
impl Display for ExtensionRegistry
Source§impl<'a> Extend<&'a Arc<Extension>> for ExtensionRegistry
 
impl<'a> Extend<&'a Arc<Extension>> for ExtensionRegistry
Source§fn extend<T: IntoIterator<Item = &'a Arc<Extension>>>(&mut self, iter: T)
 
fn extend<T: IntoIterator<Item = &'a Arc<Extension>>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
 
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
 
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<Arc<Extension>> for ExtensionRegistry
 
impl Extend<Arc<Extension>> for ExtensionRegistry
Source§fn extend<T: IntoIterator<Item = Arc<Extension>>>(&mut self, iter: T)
 
fn extend<T: IntoIterator<Item = Arc<Extension>>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
 
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
 
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a> From<&'a ExtensionRegistry> for WeakExtensionRegistry
 
impl<'a> From<&'a ExtensionRegistry> for WeakExtensionRegistry
Source§fn from(reg: &'a ExtensionRegistry) -> Self
 
fn from(reg: &'a ExtensionRegistry) -> Self
Source§impl<'a> IntoIterator for &'a ExtensionRegistry
 
impl<'a> IntoIterator for &'a ExtensionRegistry
Source§impl IntoIterator for ExtensionRegistry
 
impl IntoIterator for ExtensionRegistry
Source§impl PartialEq for ExtensionRegistry
 
impl PartialEq for ExtensionRegistry
Source§impl Serialize for ExtensionRegistry
 
impl Serialize for ExtensionRegistry
Source§impl<'a> TryFrom<&'a WeakExtensionRegistry> for ExtensionRegistry
 
impl<'a> TryFrom<&'a WeakExtensionRegistry> for ExtensionRegistry
Auto Trait Implementations§
impl !Freeze for ExtensionRegistry
impl !RefUnwindSafe for ExtensionRegistry
impl Send for ExtensionRegistry
impl Sync for ExtensionRegistry
impl Unpin for ExtensionRegistry
impl !UnwindSafe for ExtensionRegistry
Blanket Implementations§
Source§impl<I> BidiIterator for I
 
impl<I> BidiIterator for I
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
 
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
 
impl<T> DowncastSync for T
Source§impl<T> FmtForward for T
 
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
    Self: Binary,
 
fn fmt_binary(self) -> FmtBinary<Self>where
    Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
    Self: Display,
 
fn fmt_display(self) -> FmtDisplay<Self>where
    Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
    Self: LowerExp,
 
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
    Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
    Self: LowerHex,
 
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
    Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
    Self: Octal,
 
fn fmt_octal(self) -> FmtOctal<Self>where
    Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
    Self: Pointer,
 
fn fmt_pointer(self) -> FmtPointer<Self>where
    Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
    Self: UpperExp,
 
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
    Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
    Self: UpperHex,
 
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
    Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pipe for Twhere
    T: ?Sized,
 
impl<T> Pipe for Twhere
    T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
    Self: Sized,
 
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
    Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
    R: 'a,
 
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
    R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
    R: 'a,
 
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
    R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
 
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
    &'a mut self,
    func: impl FnOnce(&'a mut B) -> R,
) -> R
 
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
 
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
 
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
 
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Serialize for T
 
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> Tap for T
 
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
 
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
 
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
 
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
 
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
 
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
 
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
 
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
 
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
 
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
 
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
 
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
 
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
 
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.