Skip to content

Commit

Permalink
chore: rename to ferrunix
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandros committed Oct 9, 2024
1 parent f16264c commit 24ca75a
Show file tree
Hide file tree
Showing 27 changed files with 76 additions and 36 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
[workspace]
resolver = "2"
members = [
"rusty-injector",
"rusty-injector-*",
"ferrunix",
"ferrunix-*",
"examples/*",
"xtask",
]
# Only check / build main crates by default (check all with `--workspace`)
default-members = ["rusty-injector", "rusty-injector-*"]
default-members = ["ferrunix", "ferrunix-*"]

[workspace.package]
rust-version = "1.64"
edition = "2021"
authors = ["Arvid Gerstmann <[email protected]>"]
homepage = "https://github.com/Leandros/rusty-injector"
repository = "https://github.com/Leandros/rusty-injector"
homepage = "https://github.com/Leandros/ferrunix"
repository = "https://github.com/Leandros/ferrunix"
readme = "README.md"
license = "MIT OR Apache-2.0"
keywords = ["dependency-injection", "inversion-of-control", "dependency-inversion", "di", "ioc"]
categories = ["development-tools", "rust-patterns", "config", "data-structures"]
exclude = ["*.png", "*.svg", "rustfmt.toml", "xtask"]

[workspace.dependencies]
rusty-injector = { path = "./rusty-injector" }
rusty-injector-core = { path = "./rusty-injector-core" }
rusty-injector-macros = { path = "./rusty-injector-macros" }
ferrunix = { path = "./ferrunix" }
ferrunix-core = { path = "./ferrunix-core" }
ferrunix-macros = { path = "./ferrunix-macros" }

# Lints from compiler.
[workspace.lints.rust]
Expand Down
51 changes: 45 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,59 @@
# Rusty Injector
# Ferrunix

[![Build Status](https://github.com/leandros/rusty-injector/actions/workflows/ci.yaml/badge.svg)](https://github.com/leandros/rusty-injector/actions)
[![Crates.io](https://img.shields.io/crates/v/rusty-injector.svg)](https://crates.io/crates/rusty-injector)
[![API reference](https://docs.rs/rusty-injector/badge.svg)](https://docs.rs/rusty-injector/)
[![Build Status](https://github.com/leandros/ferrunix/actions/workflows/ci.yaml/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, and idiomatic way to inject dependencies.
A simple, idiomatic, and lightweight dependency injection framework for Rust.

```toml
[dependencies]
rusty-injector = "0"
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<Logger>,
}

impl Worker {
pub fn new(logger: Box<Logger>) -> 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<Logger>,)>()
.transient(|(logger,)| Worker::new(logger));

let worker = registry.get_transient::<Worker>().unwrap();
worker.do_work();
}
```

#### License

<sup>
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ license.workspace = true
workspace = true

[dependencies]
rusty-injector.workspace = true
ferrunix.workspace = true
2 changes: 1 addition & 1 deletion examples/simple/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Simple example for rusty-injector.
//! Simple example for ferrunix.
fn main() {
println!("Hello!");
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions rusty-injector-core/Cargo.toml → ferrunix-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rusty-injector-core"
name = "ferrunix-core"
version = "0.1.0"
description = "Core types, traits, and implementations for rusty-injector"
description = "Core types, traits, and implementations for ferrunix"
# Inherited.
rust-version.workspace = true
edition.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(clippy::unwrap_used, dead_code)]

use rusty_injector::{Registry, Singleton, Transient};
use ferrunix_core::{Registry, Singleton, Transient};

#[test]
fn simple_registry_concrete_types() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rusty-injector-macros"
name = "ferrunix-macros"
version = "0.1.0"
description = "Proc-macro for rusty-injector"
description = "Proc-macro for ferrunix"
# Inherited.
rust-version.workspace = true
edition.workspace = true
Expand All @@ -24,7 +24,7 @@ default = ["development"]
development = ["syn/extra-traits", "dep:prettyplease"]

[dependencies]
rusty-injector-core.workspace = true
ferrunix-core.workspace = true

syn = { version = "2", features = ["extra-traits"] }
prettyplease = { version = "0.2", optional = true }
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ pub fn derive_inject(

#[automatically_derived]
impl #struct_name {
pub(crate) fn register(registry: &mut ::rusty_injector::Registry) {
pub(crate) fn register(registry: &mut ::ferrunix::Registry) {
#registration
}
}

::rusty_injector::inventory_submit!(::rusty_injector::RegistrationFunc(|registry| {
::ferrunix::inventory_submit!(::ferrunix::RegistrationFunc(|registry| {
<#struct_name>::register(registry);
}));
}
Expand Down Expand Up @@ -120,7 +120,7 @@ fn build_registration_transient(
quote! {
registry
.with_deps::<Box<#raw_ty>, (
#(::rusty_injector::Transient<#types>),*
#(::ferrunix::Transient<#types>),*
)>()
.transient(|(#(#idents),*)| {
Box::new(#construct)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use super::common::*;
use rusty_injector::Registry;
use rusty_injector_macros::Inject;
use ferrunix::Registry;
use ferrunix_macros::Inject;

pub trait CreditCardProcessor: Send + Sync {
fn charge(&self, creditcard: &CreditCard, amount: i32) -> Result<i32, Error>;
Expand Down Expand Up @@ -74,7 +74,7 @@ impl BillingService for RealBillingService {
// mod __inner_register_creditcardprocessor {
// #![allow(unused_imports)]
// use super::*;
// use rusty_injector::{inventory_submit, RegistrationFunc, Registry, Singleton, Transient};
// use ferrunix::{inventory_submit, RegistrationFunc, Registry, Singleton, Transient};

// impl PaypalCreditCardProcessor {
// pub(crate) fn register(registry: &mut Registry) {
Expand All @@ -92,7 +92,7 @@ impl BillingService for RealBillingService {
// mod __inner_register_transactionlog {
// #![allow(unused_imports)]
// use super::*;
// use rusty_injector::{inventory_submit, RegistrationFunc, Registry, Singleton, Transient};
// use ferrunix::{inventory_submit, RegistrationFunc, Registry, Singleton, Transient};

// impl RealTransactionLog {
// pub(crate) fn register(registry: &mut Registry) {
Expand All @@ -109,7 +109,7 @@ impl BillingService for RealBillingService {
// mod __inner_register_realbillingservice {
// #![allow(unused_imports)]
// use super::*;
// use rusty_injector::{inventory_submit, RegistrationFunc, Registry, Singleton, Transient};
// use ferrunix::{inventory_submit, RegistrationFunc, Registry, Singleton, Transient};

// impl RealBillingService {
// pub(crate) fn register(registry: &mut Registry) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ferrunix_core::{Registry, Transient};

use super::common::*;
use rusty_injector::{Registry, Transient};

pub trait BillingService: Send + Sync {
fn charge_order(&self, order: PizzaOrder, creditcard: &CreditCard) -> Result<Receipt, Error>;
Expand Down
10 changes: 5 additions & 5 deletions rusty-injector/Cargo.toml → ferrunix/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rusty-injector"
name = "ferrunix"
version = "0.1.0"
description = "A lightweight run-time dependency injection framework for Rust"
# Inherited.
Expand All @@ -18,11 +18,11 @@ categories.workspace = true

[features]
default = ["multithread", "derive"]
multithread = ["rusty-injector-core/multithread"]
derive = ["dep:rusty-injector-macros"]
multithread = ["ferrunix-core/multithread"]
derive = ["dep:ferrunix-macros"]

[dependencies]
rusty-injector-core = { path = "../rusty-injector-core", default-features = false }
ferrunix-core = { path = "../ferrunix-core", default-features = false }

# Optional dependencies
rusty-injector-macros = { workspace = true, optional = true }
ferrunix-macros = { workspace = true, optional = true }
File renamed without changes.

0 comments on commit 24ca75a

Please sign in to comment.