pub trait Extract<T> {
// Required method
fn extract(app: &AppBuilder) -> Result<T, AppError>;
// Provided method
fn dependencies() -> Dependencies { ... }
}Expand description
Trait for extracting owned values from the application builder.
This trait allows extracting components or service handles from the application
by value. The extracted value must implement Clone to be extracted this way.
§Type Parameters
T- The type to extract from the application.
§Examples
use diode::{AppBuilder, AppError, Extract};
struct ConfigExtractor;
impl Extract<String> for ConfigExtractor {
fn extract(app: &AppBuilder) -> Result<String, AppError> {
app.get_component::<String>()
.ok_or(AppError::MissingDependency)
}
}Required Methods§
Provided Methods§
Sourcefn dependencies() -> Dependencies
fn dependencies() -> Dependencies
Returns the dependencies required by this type.
The default implementation returns an empty dependencies set, indicating no dependencies are required.
§Returns
A Dependencies object describing required dependencies.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.