diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 871900d..6ccd265 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,8 +72,9 @@ jobs: components: rust-src - uses: dtolnay/install@cargo-docs-rs - run: | - cargo docs-rs -p rusty-injector - cargo docs-rs -p rusty-injector-macros + cargo docs-rs -p ferrunix + cargo docs-rs -p ferrunix-core + cargo docs-rs -p ferrunix-macros clippy: name: Clippy diff --git a/README.md b/README.md deleted file mode 100644 index 17c5e51..0000000 --- a/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Ferrunix - -[![Build Status](https://github.com/leandros/ferrunix/actions/workflows/ci.yml/badge.svg)](https://github.com/leandros/ferrunix/actions) -[![Crates.io](https://img.shields.io/crates/v/ferrunix.svg)](https://crates.io/crates/ferrunix) -[![API reference](https://docs.rs/ferrunix/badge.svg)](https://docs.rs/ferrunix/) - -A simple, idiomatic, and lightweight dependency injection framework for Rust. - -```toml -[dependencies] -ferrunix = "0" -``` - -*Compiler support: requires rustc 1.62+* - -## Example - -```rust -use ferrunix::{Registry, Transient}; - -#[derive(Default, Debug)] -pub struct Logger {} - -impl Logger { - pub fn info(&self, message: &str) { - println!("INFO: {message}"); - } -} - -#[derive(Debug)] -pub struct Worker { - logger: Box, -} - -impl Worker { - pub fn new(logger: Box) -> Self { - Self { logger } - } - - pub fn do_work(&self) { - self.logger.info("doing something ..."); - } -} - -fn main() { - let mut registry = Registry::empty(); - registry.transient(|| Logger::default()); - registry - .with_deps::<_, (Transient,)>() - .transient(|(logger,)| Worker::new(logger)); - - let worker = registry.get_transient::().unwrap(); - worker.do_work(); -} -``` - -#### License - - -Licensed under either of Apache License, Version -2.0 or MIT license at your option. - - -
- - -By contributing to this project (for example, through submitting a pull -request) you agree with the [individual contributor license -agreement](Contributors-License-Agreement.md). Make sure to read and understand -it. - diff --git a/README.md b/README.md new file mode 120000 index 0000000..b1efaa9 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +ferrunix/README.md \ No newline at end of file diff --git a/book/book.toml b/book/book.toml index 76461f1..857a008 100644 --- a/book/book.toml +++ b/book/book.toml @@ -3,4 +3,4 @@ authors = ["Arvid Gerstmann"] language = "en" multilingual = false src = "src" -title = "Rusty Injector Documentation" +title = "Ferrunix Documentation" diff --git a/ferrunix-core/Cargo.toml b/ferrunix-core/Cargo.toml index b1dd840..ac205f3 100644 --- a/ferrunix-core/Cargo.toml +++ b/ferrunix-core/Cargo.toml @@ -2,13 +2,13 @@ name = "ferrunix-core" version = "0.1.0" description = "Core types, traits, and implementations for ferrunix" +readme = "README.md" # Inherited. rust-version.workspace = true edition.workspace = true authors.workspace = true homepage.workspace = true repository.workspace = true -readme.workspace = true license.workspace = true keywords.workspace = true categories.workspace = true diff --git a/ferrunix-core/README.md b/ferrunix-core/README.md new file mode 100644 index 0000000..9011f09 --- /dev/null +++ b/ferrunix-core/README.md @@ -0,0 +1,26 @@ +# Ferrunix Core + +[![Build Status](https://github.com/leandros/ferrunix/actions/workflows/ci.yml/badge.svg)](https://github.com/leandros/ferrunix/actions) +[![Crates.io](https://img.shields.io/crates/v/ferrunix-core.svg)](https://crates.io/crates/ferrunix-core) +[![API reference](https://docs.rs/ferrunix-core/badge.svg)](https://docs.rs/ferrunix-core/) + +Core types, traits, and implementations for [ferrunix](https://crates.io/crates/ferrunix). + +More information about this crate can be found in the [crate documentation](https://docs.rs/ferrunix-core/). + + +#### License + + +Licensed under either of Apache License, Version +2.0 or MIT license at your option. + + +
+ + +By contributing to this project (for example, through submitting a pull +request) you agree with the [individual contributor license +agreement](https://github.com/Leandros/ferrunix/blob/master/Contributors-License-Agreement.md). +Make sure to read and understand it. + diff --git a/ferrunix-macros/Cargo.toml b/ferrunix-macros/Cargo.toml index 0fd7964..dc125ce 100644 --- a/ferrunix-macros/Cargo.toml +++ b/ferrunix-macros/Cargo.toml @@ -2,13 +2,13 @@ name = "ferrunix-macros" version = "0.1.0" description = "Proc-macro for ferrunix" +readme = "README.md" # Inherited. rust-version.workspace = true edition.workspace = true authors.workspace = true homepage.workspace = true repository.workspace = true -readme.workspace = true license.workspace = true keywords.workspace = true categories.workspace = true diff --git a/ferrunix-macros/README.md b/ferrunix-macros/README.md new file mode 100644 index 0000000..b00f9e5 --- /dev/null +++ b/ferrunix-macros/README.md @@ -0,0 +1,26 @@ +# Ferrunix Macros + +[![Build Status](https://github.com/leandros/ferrunix/actions/workflows/ci.yml/badge.svg)](https://github.com/leandros/ferrunix/actions) +[![Crates.io](https://img.shields.io/crates/v/ferrunix-macros.svg)](https://crates.io/crates/ferrunix-macros) +[![API reference](https://docs.rs/ferrunix-macros/badge.svg)](https://docs.rs/ferrunix-macros/) + +Proc-macro for [ferrunix](https://crates.io/crates/ferrunix). + +More information about this crate can be found in the [crate documentation](https://docs.rs/ferrunix-macros/). + + +#### License + + +Licensed under either of Apache License, Version +2.0 or MIT license at your option. + + +
+ + +By contributing to this project (for example, through submitting a pull +request) you agree with the [individual contributor license +agreement](https://github.com/Leandros/ferrunix/blob/master/Contributors-License-Agreement.md). +Make sure to read and understand it. + diff --git a/ferrunix/Cargo.toml b/ferrunix/Cargo.toml index b7a5396..1ddfb6d 100644 --- a/ferrunix/Cargo.toml +++ b/ferrunix/Cargo.toml @@ -2,13 +2,13 @@ name = "ferrunix" version = "0.1.0" description = "A lightweight run-time dependency injection framework for Rust" +readme = "README.md" # Inherited. rust-version.workspace = true edition.workspace = true authors.workspace = true homepage.workspace = true repository.workspace = true -readme.workspace = true license.workspace = true keywords.workspace = true categories.workspace = true diff --git a/ferrunix/README.md b/ferrunix/README.md new file mode 100644 index 0000000..a56952f --- /dev/null +++ b/ferrunix/README.md @@ -0,0 +1,71 @@ +# Ferrunix + +[![Build Status](https://github.com/leandros/ferrunix/actions/workflows/ci.yml/badge.svg)](https://github.com/leandros/ferrunix/actions) +[![Crates.io](https://img.shields.io/crates/v/ferrunix.svg)](https://crates.io/crates/ferrunix) +[![API reference](https://docs.rs/ferrunix/badge.svg)](https://docs.rs/ferrunix/) + +A simple, idiomatic, and lightweight dependency injection framework for Rust. + +```toml +[dependencies] +ferrunix = "0" +``` + +*Compiler support: requires rustc 1.64+* + +## Example + +```rust +use ferrunix::{Registry, Transient}; + +#[derive(Default, Debug)] +pub struct Logger {} + +impl Logger { + pub fn info(&self, message: &str) { + println!("INFO: {message}"); + } +} + +#[derive(Debug)] +pub struct Worker { + logger: Box, +} + +impl Worker { + pub fn new(logger: Box) -> Self { + Self { logger } + } + + pub fn do_work(&self) { + self.logger.info("doing something ..."); + } +} + +fn main() { + let mut registry = Registry::empty(); + registry.transient(|| Logger::default()); + registry + .with_deps::<_, (Transient,)>() + .transient(|(logger,)| Worker::new(logger)); + + let worker = registry.get_transient::().unwrap(); + worker.do_work(); +} +``` + +#### License + + +Licensed under either of Apache License, Version +2.0 or MIT license at your option. + + +
+ + +By contributing to this project (for example, through submitting a pull +request) you agree with the [individual contributor license +agreement](https://github.com/Leandros/ferrunix/blob/master/Contributors-License-Agreement.md). +Make sure to read and understand it. +