Skip to content

Commit

Permalink
Rust doc improved
Browse files Browse the repository at this point in the history
  • Loading branch information
idugalic committed Oct 19, 2023
1 parent 7fc2293 commit f863277
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(missing_docs)]
//! # FModel Rust
//!
//! When you’re developing an information system to automate the activities of the business, you are modeling the business.
Expand Down Expand Up @@ -152,11 +153,17 @@
//! ---
//! Created with `love` by [Fraktalio](https://fraktalio.com/)
/// Aggregate module - belongs to the Application layer.
pub mod aggregate;
/// Decider module - belongs to the Domain layer.
pub mod decider;
/// Materialized View module - belongs to the Application layer.
pub mod materialized_view;
/// Saga module - belongs to the Domain layer.
pub mod saga;
/// Saga Manager module - belongs to the Application layer.
pub mod saga_manager;
/// View module - belongs to the Domain layer.
pub mod view;

/// The [DecideFunction] function is used to decide which events to produce based on the command and the current state.
Expand Down
1 change: 1 addition & 0 deletions src/materialized_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ where
Repository: ViewStateRepository<E, S, Error>,
View: ViewStateComputation<E, S>,
{
/// Creates a new instance of [MaterializedView].
pub fn new(repository: Repository, view: View) -> Self {
MaterializedView {
repository,
Expand Down
2 changes: 2 additions & 0 deletions src/saga_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::saga::Saga;
/// - `Error` - error
#[async_trait]
pub trait ActionPublisher<A, Error> {
/// Publishes the action/command to some external system, returning either the actions that are successfully published or error.
async fn publish(&self, action: &[A]) -> Result<Vec<A>, Error>;
}

Expand All @@ -38,6 +39,7 @@ impl<'a, A, AR, Publisher, Error> SagaManager<'a, A, AR, Publisher, Error>
where
Publisher: ActionPublisher<A, Error>,
{
/// Creates a new instance of [SagaManager].
pub fn new(action_publisher: Publisher, saga: Saga<'a, AR, A>) -> Self {
SagaManager {
action_publisher,
Expand Down
1 change: 1 addition & 0 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl<'a, S, E> View<'a, S, E> {
}
}

/// Formalizes the `State Computation` algorithm for the `view` to handle events based on the current state, and produce new state.
pub trait ViewStateComputation<E, S> {
/// Computes new state based on the current state and the events.
fn compute_new_state(&self, current_state: Option<S>, events: &[&E]) -> S;
Expand Down

0 comments on commit f863277

Please sign in to comment.