Struct options::OptionsBuilder

source ·
pub struct OptionsBuilder<'a, T: 'static> { /* private fields */ }
Available on crate feature di only.
Expand description

Represents a builder used to configure Options.

Implementations§

source§

impl<'a, T: 'static> OptionsBuilder<'a, T>

source

pub fn new(services: &'a mut ServiceCollection, name: Option<&str>) -> Self

Initializes a new options builder.

Arguments
source

pub fn name(&self) -> Option<&str>

Gets the name of the options

source

pub fn services(&mut self) -> &mut ServiceCollection

Gets the associated collection of services

source

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

Registers an action used to configure a particular type of Options.

Arguments
  • setup - The configuration action
source

pub fn configure1<F, D>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D>) + 'static, D: 'static,

Registers an action used to configure a particular type of Options with a single dependency.

Arguments
  • setup - The configuration action
source

pub fn configure2<F, D1, D2>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>) + 'static, D1: 'static, D2: 'static,

Registers an action used to configure a particular type of Options with two dependencies.

Arguments
  • setup - The configuration action
source

pub fn configure3<F, D1, D2, D3>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>, Ref<D3>) + 'static, D1: 'static, D2: 'static, D3: 'static,

Registers an action used to configure a particular type of Options with three dependencies.

Arguments
  • setup - The configuration action
source

pub fn configure4<F, D1, D2, D3, D4>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>, Ref<D3>, Ref<D4>) + 'static, D1: 'static, D2: 'static, D3: 'static, D4: 'static,

Registers an action used to configure a particular type of Options with four dependencies.

Arguments
  • setup - The configuration action
source

pub fn configure5<F, D1, D2, D3, D4, D5>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>, Ref<D3>, Ref<D4>, Ref<D5>) + 'static, D1: 'static, D2: 'static, D3: 'static, D4: 'static, D5: 'static,

Registers an action used to configure a particular type of Options with five dependencies.

Arguments
  • setup - The configuration action
source

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

Registers an action used to configure a particular type of Options.

Arguments
  • setup - The configuration action
source

pub fn post_configure1<F, D>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D>) + 'static, D: 'static,

Registers an action used to configure a particular type of Options with a single dependency.

Arguments
  • setup - The configuration action
source

pub fn post_configure2<F, D1, D2>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>) + 'static, D1: 'static, D2: 'static,

Registers an action used to configure a particular type of Options with two dependencies.

Arguments
  • setup - The configuration action
source

pub fn post_configure3<F, D1, D2, D3>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>, Ref<D3>) + 'static, D1: 'static, D2: 'static, D3: 'static,

Registers an action used to configure a particular type of Options with three dependencies.

Arguments
  • setup - The configuration action
source

pub fn post_configure4<F, D1, D2, D3, D4>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>, Ref<D3>, Ref<D4>) + 'static, D1: 'static, D2: 'static, D3: 'static, D4: 'static,

Registers an action used to configure a particular type of Options with four dependencies.

Arguments
  • setup - The configuration action
source

pub fn post_configure5<F, D1, D2, D3, D4, D5>(self, setup: F) -> Self
where F: Fn(&mut T, Ref<D1>, Ref<D2>, Ref<D3>, Ref<D4>, Ref<D5>) + 'static, D1: 'static, D2: 'static, D3: 'static, D4: 'static, D5: 'static,

Registers an action used to configure a particular type of Options with five dependencies.

Arguments
  • setup - The configuration action
source

pub fn validate<F, M>(self, action: F, failure_message: M) -> Self
where F: Fn(&T) -> bool + 'static, M: AsRef<str>,

Registers an action used to validate a particular type of Options.

Arguments
  • action - The validation action
  • failure_message - The message used when validation fails
source

pub fn validate1<F, M, D>(self, action: F, failure_message: M) -> Self
where F: Fn(&T, Ref<D>) -> bool + 'static, M: AsRef<str>, D: 'static,

Registers an action used to validate a particular type of Options with a single dependency.

Arguments
  • action - The validation action
  • failure_message - The message used when validation fails
source

pub fn validate2<F, M, D1, D2>(self, action: F, failure_message: M) -> Self
where F: Fn(&T, Ref<D1>, Ref<D2>) -> bool + 'static, M: AsRef<str>, D1: 'static, D2: 'static,

Registers an action used to validate a particular type of Options with two dependencies.

Arguments
  • action - The validation action
  • failure_message - The message used when validation fails
source

pub fn validate3<F, M, D1, D2, D3>(self, action: F, failure_message: M) -> Self
where F: Fn(&T, Ref<D1>, Ref<D2>, Ref<D3>) -> bool + 'static, M: AsRef<str>, D1: 'static, D2: 'static, D3: 'static,

Registers an action used to validate a particular type of Options with three dependencies.

Arguments
  • action - The validation action
  • failure_message - The message used when validation fails
source

pub fn validate4<F, M, D1, D2, D3, D4>( self, action: F, failure_message: M ) -> Self
where F: Fn(&T, Ref<D1>, Ref<D2>, Ref<D3>, Ref<D4>) -> bool + 'static, M: AsRef<str>, D1: 'static, D2: 'static, D3: 'static, D4: 'static,

Registers an action used to validate a particular type of Options with four dependencies.

Arguments
  • action - The validation action
  • failure_message - The message used when validation fails
source

pub fn validate5<F, M, D1, D2, D3, D4, D5>( self, action: F, failure_message: M ) -> Self
where F: Fn(&T, Ref<D1>, Ref<D2>, Ref<D3>, Ref<D4>, Ref<D5>) -> bool + 'static, M: AsRef<str>, D1: 'static, D2: 'static, D3: 'static, D4: 'static, D5: 'static,

Registers an action used to validate a particular type of Options with five dependencies.

Arguments
  • action - The validation action
  • failure_message - The message used when validation fails

Methods from Deref<Target = ServiceCollection>§

source

pub fn is_empty(&self) -> bool

Returns true if the collection contains no elements.

source

pub fn len(&self) -> usize

Returns the number of elements in the collection.

source

pub fn clear(&mut self)

Removes all elements from the collection.

source

pub fn remove(&mut self, index: usize) -> ServiceDescriptor

Removes and returns the element at position index within the collection.

Argument
  • index - The index of the element to remove
Panics

Panics if index is out of bounds.

source

pub fn add<T>(&mut self, descriptor: T) -> &mut ServiceCollection

Adds a service using the specified service descriptor.

Arguments
source

pub fn try_add<T>(&mut self, descriptor: T) -> &mut ServiceCollection

Adds a service using the specified service descriptor if the service has not already been registered.

Arguments
source

pub fn try_add_to_all<T>(&mut self, descriptor: T) -> &mut ServiceCollection

Adds a service using the specified service descriptor if the service with same service and implementation type has not already been registered.

Arguments
source

pub fn try_add_all( &mut self, descriptors: impl IntoIterator<Item = ServiceDescriptor> ) -> &mut ServiceCollection

Adds the specified service descriptors if each of the services are not already registered with the same service and implementation type.

Arguments
source

pub fn replace<T>(&mut self, descriptor: T) -> &mut ServiceCollection

Removes the first service descriptor with the same service type and adds the replacement.

Arguments
source

pub fn try_replace<T>(&mut self, descriptor: T) -> &mut ServiceCollection

Adds or replaces a service with the specified descriptor if the service has not already been registered.

Arguments
source

pub fn remove_all<T>(&mut self) -> &mut ServiceCollection
where T: Any + ?Sized,

Removes all specified descriptors of the specified type.

source

pub fn build_provider(&self) -> Result<ServiceProvider, ValidationError>

Builds and returns a new ServiceProvider.

source

pub fn iter( &self ) -> impl Iterator<Item = &ServiceDescriptor> + ExactSizeIterator + DoubleEndedIterator

Gets a read-only iterator for the collection

Trait Implementations§

source§

impl<'a, T> Deref for OptionsBuilder<'a, T>

§

type Target = ServiceCollection

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, T> DerefMut for OptionsBuilder<'a, T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, T> Into<&'a mut ServiceCollection> for OptionsBuilder<'a, T>

source§

fn into(self) -> &'a mut ServiceCollection

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for OptionsBuilder<'a, T>

§

impl<'a, T> !Send for OptionsBuilder<'a, T>

§

impl<'a, T> !Sync for OptionsBuilder<'a, T>

§

impl<'a, T> Unpin for OptionsBuilder<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for OptionsBuilder<'a, T>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.