pub struct Constructor { /* private fields */ }
Expand description
A constructor that has been configured but has not yet been registered with a Blueprint
.
§Guide
Check out the “Dependency injection” section of Pavex’s guide for a thorough introduction to dependency injection in Pavex applications.
§Use cases
Constructor
is primarily used by kits (e.g. ApiKit
)
to allow users to customize (or disable!)
the bundled constructors before registering them with a Blueprint
.
Implementations§
Source§impl Constructor
impl Constructor
Sourcepub fn new(callable: RawIdentifiers, lifecycle: Lifecycle) -> Self
pub fn new(callable: RawIdentifiers, lifecycle: Lifecycle) -> Self
Create a new (unregistered) constructor.
Check out the documentation of Blueprint::constructor
for more details
on constructors.
Sourcepub fn singleton(callable: RawIdentifiers) -> Self
pub fn singleton(callable: RawIdentifiers) -> Self
Create a new (unregistered) constructor with a singleton lifecycle.
It’s a shorthand for Constructor::new(callable, Lifecycle::Singleton)
.
Sourcepub fn request_scoped(callable: RawIdentifiers) -> Self
pub fn request_scoped(callable: RawIdentifiers) -> Self
Create a new (unregistered) constructor with a request-scoped lifecycle.
It’s a shorthand for Constructor::new(callable, Lifecycle::RequestScoped)
.
Sourcepub fn transient(callable: RawIdentifiers) -> Self
pub fn transient(callable: RawIdentifiers) -> Self
Create a new (unregistered) constructor with a transient lifecycle.
It’s a shorthand for Constructor::new(callable, Lifecycle::Transient)
.
Sourcepub fn error_handler(self, error_handler: RawIdentifiers) -> Self
pub fn error_handler(self, error_handler: RawIdentifiers) -> Self
Register an error handler for this constructor.
Check out the documentation of RegisteredConstructor::error_handler
for more details.
Sourcepub fn cloning(self, cloning_strategy: CloningStrategy) -> Self
pub fn cloning(self, cloning_strategy: CloningStrategy) -> Self
Set the cloning strategy for the output type returned by this constructor.
Check out the documentation of CloningStrategy
for more details.
Sourcepub fn clone_if_necessary(self) -> Self
pub fn clone_if_necessary(self) -> Self
Set the cloning strategy to CloningStrategy::CloneIfNecessary
.
Check out Constructor::cloning
for more details.
Sourcepub fn never_clone(self) -> Self
pub fn never_clone(self) -> Self
Set the cloning strategy to CloningStrategy::NeverClone
.
Check out Constructor::cloning
for more details.
Sourcepub fn ignore(self, lint: Lint) -> Self
pub fn ignore(self, lint: Lint) -> Self
Tell Pavex to ignore a specific Lint
when analysing
this constructor and the way it’s used.
Sourcepub fn enforce(self, lint: Lint) -> Self
pub fn enforce(self, lint: Lint) -> Self
Tell Pavex to enforce a specific Lint
when analysing
this constructor and the way it’s used.
Sourcepub fn register(self, bp: &mut Blueprint) -> RegisteredConstructor<'_>
pub fn register(self, bp: &mut Blueprint) -> RegisteredConstructor<'_>
Register this constructor with a Blueprint
.
Check out the documentation of Blueprint::constructor
for more details.
Trait Implementations§
Source§impl Clone for Constructor
impl Clone for Constructor
Source§fn clone(&self) -> Constructor
fn clone(&self) -> Constructor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more