OptionsServiceExtensions

Trait OptionsServiceExtensions 

Source
pub trait OptionsServiceExtensions {
    // Required methods
    fn add_options<T: Value + Default + 'static>(
        &mut self,
    ) -> OptionsBuilder<'_, T>;
    fn add_named_options<T: Value + Default + 'static>(
        &mut self,
        name: impl AsRef<str>,
    ) -> OptionsBuilder<'_, T>;
    fn add_options_with<T, F>(&mut self, factory: F) -> OptionsBuilder<'_, T>
       where T: Value,
             F: Fn(&ServiceProvider) -> Ref<dyn OptionsFactory<T>> + 'static;
    fn add_named_options_with<T, F>(
        &mut self,
        name: impl AsRef<str>,
        factory: F,
    ) -> OptionsBuilder<'_, T>
       where T: Value,
             F: Fn(&ServiceProvider) -> Ref<dyn OptionsFactory<T>> + 'static;
    fn configure_options<T, F>(&mut self, setup: F) -> &mut Self
       where T: Value + Default + 'static,
             F: Fn(&mut T) + 'static;
    fn configure_named_options<T, F>(
        &mut self,
        name: impl AsRef<str>,
        setup: F,
    ) -> &mut Self
       where T: Value + Default + 'static,
             F: Fn(&mut T) + 'static;
    fn post_configure_options<T, F>(&mut self, setup: F) -> &mut Self
       where T: Value + Default + 'static,
             F: Fn(&mut T) + 'static;
    fn post_configure_named_options<T, F>(
        &mut self,
        name: impl AsRef<str>,
        setup: F,
    ) -> &mut Self
       where T: Value + Default + 'static,
             F: Fn(&mut T) + 'static;
}
Available on crate feature di only.
Expand description

Defines extension methods for the ServiceCollection struct.

Required Methods§

Source

fn add_options<T: Value + Default + 'static>(&mut self) -> OptionsBuilder<'_, T>

Registers an options type that will have all of its associated services registered.

Source

fn add_named_options<T: Value + Default + 'static>( &mut self, name: impl AsRef<str>, ) -> OptionsBuilder<'_, T>

Registers an options type that will have all of its associated services registered.

§Arguments
  • name - The name associated with the options
Source

fn add_options_with<T, F>(&mut self, factory: F) -> OptionsBuilder<'_, T>
where T: Value, F: Fn(&ServiceProvider) -> Ref<dyn OptionsFactory<T>> + 'static,

Registers an options type that will have all of its associated services registered.

§Arguments
  • factory - The function used to create the associated options factory
Source

fn add_named_options_with<T, F>( &mut self, name: impl AsRef<str>, factory: F, ) -> OptionsBuilder<'_, T>
where T: Value, F: Fn(&ServiceProvider) -> Ref<dyn OptionsFactory<T>> + 'static,

Registers an options type that will have all of its associated services registered.

§Arguments
  • name - The name associated with the options
  • factory - The function used to create the associated options factory
Source

fn configure_options<T, F>(&mut self, setup: F) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Registers an action used to initialize a particular type of configuration options.

§Arguments
  • setup - The setup action used to configure options.
Source

fn configure_named_options<T, F>( &mut self, name: impl AsRef<str>, setup: F, ) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Registers an action used to initialize a particular type of configuration options.

§Arguments
  • name - The name associated with the options
  • setup - The setup action used to configure options
Source

fn post_configure_options<T, F>(&mut self, setup: F) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Registers an action used to initialize a particular type of configuration options.

§Arguments
  • setup - The setup action used to configure options
Source

fn post_configure_named_options<T, F>( &mut self, name: impl AsRef<str>, setup: F, ) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Registers an action used to initialize a particular type of configuration options.

§Arguments
  • name - The name associated with the options
  • setup - The setup action used to configure options

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OptionsServiceExtensions for ServiceCollection

Source§

fn add_options<T: Value + Default + 'static>(&mut self) -> OptionsBuilder<'_, T>

Source§

fn add_named_options<T: Value + Default + 'static>( &mut self, name: impl AsRef<str>, ) -> OptionsBuilder<'_, T>

Source§

fn add_options_with<T, F>(&mut self, factory: F) -> OptionsBuilder<'_, T>
where T: Value, F: Fn(&ServiceProvider) -> Ref<dyn OptionsFactory<T>> + 'static,

Source§

fn add_named_options_with<T, F>( &mut self, name: impl AsRef<str>, factory: F, ) -> OptionsBuilder<'_, T>
where T: Value, F: Fn(&ServiceProvider) -> Ref<dyn OptionsFactory<T>> + 'static,

Source§

fn configure_options<T, F>(&mut self, setup: F) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Source§

fn configure_named_options<T, F>( &mut self, name: impl AsRef<str>, setup: F, ) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Source§

fn post_configure_options<T, F>(&mut self, setup: F) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Source§

fn post_configure_named_options<T, F>( &mut self, name: impl AsRef<str>, setup: F, ) -> &mut Self
where T: Value + Default + 'static, F: Fn(&mut T) + 'static,

Implementors§