Struct dfdi_core::Context

source ·
pub struct Context<'pcx> { /* private fields */ }
Expand description

A context in which to store providers for services

Implementations

Create an empty context

Create a sub-context

The retuned context will contain the same elements as the parent context and any elements added to the sub context will not be visible on the original. However, the underlying providers that were added before this call are shared between the two contexts.

Register a new provider for the service S

Panics

If the service binding fails. See try_bind_with for a fallible version of this function.

Register a function as a provider for the service S

Panics

If the service binding fails. See try_bind_fn for a fallible version of this function.

Bind the provider P to the service S

Panics

If the service binding fails. See try_bind for a fallible version of this function.

Delete the provider bound to the service S

Panics

If the service unbinding fails. See try_unbind for a fallible version of this function.

Resolve the service S based on the already registered providers

Panics

If no provider is registered for this service. See try_resolve for a fallible version of this function.

Try to register a new provider for the service S

Fails

This function will fail if a provider is already bound to the service.

See bind_with for the panicking version of this function.

Try to register a function as a provider for the service S

Fails

This function will fail if a provider is already bound to the service.

See bind_fn for the panicking version of this function.

Try to bind the provider P to the service S

Fails

This function will fail if a provider is already bound to the service.

See bind for the panicking version of this function.

Try to delete the provider bound to the service S

Fails

This function will fail if no provider is bound to the service.

See unbind for the panicking version of this function.

Try to resolve the service S based on the already registered providers

Fails

This function will fail if no provider is bound to the service.

See unbind for the panicking version of this function.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.