brdd-rust 0.1.0

Business Rule Driven Design (BRDD) core components for Rust.
Documentation
  • Coverage
  • 29.03%
    9 out of 31 items documented0 out of 23 items with examples
  • Size
  • Source code size: 12.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.26 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m Average build duration of successful builds.
  • all releases: 38s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • brdd-design/brdd-rust
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • defoltech

🦀 BRDD Rust

High-performance, type-safe implementation of Business Rule Driven Design (BRDD) for the Rust ecosystem.

BRDD is an architectural pattern that puts business rules at the absolute center of software development. It decouples core logic from infrastructure, ensuring that validation and state transitions are explicit, traceable, and highly testable.

📦 Installation

Add this to your Cargo.toml:

[dependencies]
brdd-rust = "0.1.0"
serde = { version = "1.0", features = ["derive"] }

🏗️ Core Concepts

ExecutionContext

The single source of truth for a process. It tracks:

  • Data: The successful result of the operation.
  • Errors: Business rule violations (with codes and messages).
  • Setters: Intentions to change state in the database.
  • Effects: External side-effects (e.g., sending an email).

Services

  • ValidateService: Pure functions for checking business rules.
  • EnrichService: Bridges the gap between input and the data needed for rules.
  • ClientService: Adapters for infrastructure (DB, API).

🚀 Usage Example

use brdd_rust::{DefaultExecutionContext, ExecutionContext, ValidationContext};

fn main() {
    let mut ctx = DefaultExecutionContext::new(None);
    
    // Validate a rule
    if some_input_is_invalid() {
        ctx.add_error("R001".to_string(), "Input is invalid".to_string());
    }
    
    if ctx.is_valid() {
        ctx.add_setter("UPDATE_USER_STATUS".to_string());
        ctx.add_effect("SEND_WELCOME_EMAIL".to_string());
        ctx.set_data("Success".to_string());
    }
    
    println!("Status: {}", ctx.get_status());
}

fn some_input_is_invalid() -> bool { false }

🛡️ Stability

This crate is under active development. It follows the core BRDD specification used across Python, Go, and TypeScript implementations to ensure cross-language architectural consistency.

📄 License

Licensed under the MIT License.