Skip to content

0.9.1

Latest

Choose a tag to compare

@idugalic idugalic released this 14 Sep 13:30
· 7 commits to main since this release
c9736e2

fmodel-rust library is optimized for Event sourcing, CQRS, and Domain Modeling.

The goal is to accelerate the development of compositional, safe, and ergonomic applications. Fmodel uses a powerful Rust type-system to bring functional and algebraic domain modeling to Rust.

Requirements - Rust 1.75.0+

From version 0.7.0+, the library is using async fn in Traits feature, which is currently available only in stable Rust 1.75.0+.

What's Changed

  • not-send-futures feature propagated to domain components to remove Send/Sync bound by @idugalic in #74

You can enable the feature:

[dependencies]
fmodel-rust = { version = "0.9.0", features = ["not-send-futures"] }

Once enabled, the not-send-futures will remove Send/Sync bounds from deep Domain components for better ergonomics and more flexibility.

Compare the signatures of domain functions in fmodel:

/// The [DecideFunction] function is used to decide which events to produce based on the command and the current state.
#[cfg(not(feature = "not-send-futures"))]
pub type DecideFunction<'a, C, S, E, Error> =
    Box<dyn Fn(&C, &S) -> Result<Vec<E>, Error> + 'a + Send + Sync>;
/// The [EvolveFunction] function is used to evolve the state based on the current state and the event.
#[cfg(not(feature = "not-send-futures"))]
pub type EvolveFunction<'a, S, E> = Box<dyn Fn(&S, &E) -> S + 'a + Send + Sync>;
/// The [InitialStateFunction] function is used to produce the initial state.
#[cfg(not(feature = "not-send-futures"))]
pub type InitialStateFunction<'a, S> = Box<dyn Fn() -> S + 'a + Send + Sync>;
/// The [ReactFunction] function is used to decide what actions/A to execute next based on the action result/AR.
#[cfg(not(feature = "not-send-futures"))]
pub type ReactFunction<'a, AR, A> = Box<dyn Fn(&AR) -> Vec<A> + 'a + Send + Sync>;

/// The [DecideFunction] function is used to decide which events to produce based on the command and the current state.
#[cfg(feature = "not-send-futures")]
pub type DecideFunction<'a, C, S, E, Error> = Box<dyn Fn(&C, &S) -> Result<Vec<E>, Error> + 'a>;
/// The [EvolveFunction] function is used to evolve the state based on the current state and the event.
#[cfg(feature = "not-send-futures")]
pub type EvolveFunction<'a, S, E> = Box<dyn Fn(&S, &E) -> S + 'a>;
/// The [InitialStateFunction] function is used to produce the initial state.
#[cfg(feature = "not-send-futures")]
pub type InitialStateFunction<'a, S> = Box<dyn Fn() -> S + 'a>;
/// The [ReactFunction] function is used to decide what actions/A to execute next based on the action result/AR.
#[cfg(feature = "not-send-futures")]
pub type ReactFunction<'a, AR, A> = Box<dyn Fn(&AR) -> Vec<A> + 'a>;

Full Changelog: 0.9.0...0.9.1