diff --git a/ferrunix-core/Cargo.toml b/ferrunix-core/Cargo.toml index 28902cb..d65f3ab 100644 --- a/ferrunix-core/Cargo.toml +++ b/ferrunix-core/Cargo.toml @@ -17,7 +17,7 @@ categories.workspace = true workspace = true [features] -default = ["multithread", "tokio"] +default = [] multithread = ["once_cell/parking_lot"] tokio = ["dep:tokio", "dep:async-trait"] diff --git a/ferrunix/Cargo.toml b/ferrunix/Cargo.toml index f0a84b1..5631b67 100644 --- a/ferrunix/Cargo.toml +++ b/ferrunix/Cargo.toml @@ -17,7 +17,7 @@ categories.workspace = true workspace = true [features] -default = ["derive", "tokio"] +default = ["derive"] multithread = ["ferrunix-core/multithread"] derive = ["dep:ferrunix-macros"] tokio = ["ferrunix-core/tokio", "ferrunix-macros/tokio"] diff --git a/ferrunix/tests/it/derive_async.rs b/ferrunix/tests/it/derive_async.rs index d0e984d..ef5cb5d 100644 --- a/ferrunix/tests/it/derive_async.rs +++ b/ferrunix/tests/it/derive_async.rs @@ -1,4 +1,7 @@ // #![cfg(not(miri))] +#![allow(unused)] + +use std::path::PathBuf; use ferrunix::{Inject, RegistrationFunc, Registry}; @@ -27,6 +30,28 @@ use ferrunix::{Inject, RegistrationFunc, Registry}; // ferrunix::autoregister!(RegistrationFunc::new(Empty::register)); +#[derive(Inject)] +#[provides(transient)] +struct CargoToml { + contents: String, +} + +impl CargoToml { + #[allow(clippy::unwrap_used)] + pub async fn new() -> Self { + let manifest_dir = std::env::var("CARGO_MANIFEST_DIR") + .map(PathBuf::from) + .unwrap(); + let manifest_dir = manifest_dir.join("Cargo.toml"); + let contents = tokio::fs::read_to_string(manifest_dir).await.unwrap(); + + Self { contents } + } + + pub fn contents(&self) -> &str { + &self.contents + } +} #[derive(Inject)] #[provides(transient)] @@ -37,6 +62,8 @@ struct Dep0 {} struct Dep1 { #[inject(transient)] dep0: Dep0, + #[inject(ctor = "CargoToml::new().await")] + cargotoml: CargoToml, } #[derive(Inject)]