pavex/blueprint/
cloning_policy.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
2#[non_exhaustive]
3/// Determines whether Pavex is allowed to clone a type.
4///
5/// This applies to [configuration types](crate::Blueprint::config),
6/// [prebuilt types](crate::Blueprint::prebuilt) and [constructors](crate::Blueprint::constructor).
7///
8/// # Guide
9///
10/// Check out the ["Dependency injection"](https://pavex.dev/docs/guide/dependency_injection)
11/// section of Pavex's guide for a thorough introduction to dependency injection
12/// in Pavex applications.
13pub enum CloningPolicy {
14    /// Pavex is not allowed to clone the type.\
15    /// Pavex will return an error if cloning is necessary to generate code
16    /// that satisfies Rust's borrow checker.
17    NeverClone,
18    /// Pavex is allowed to clone the type.\
19    /// Pavex will invoke `.clone()` if it's necessary to generate code that
20    /// satisfies Rust's borrow checker.
21    CloneIfNecessary,
22}