Struct pavex::blueprint::constructor::Constructor
source · 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 moreAuto Trait Implementations§
impl Freeze for Constructor
impl RefUnwindSafe for Constructor
impl Send for Constructor
impl Sync for Constructor
impl Unpin for Constructor
impl UnwindSafe for Constructor
Blanket Implementations§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)