From f863277ed0cb1da919090059abe9929749266530 Mon Sep 17 00:00:00 2001 From: Ivan Dugalic Date: Thu, 19 Oct 2023 18:24:20 +0200 Subject: [PATCH] Rust doc improved --- src/lib.rs | 7 +++++++ src/materialized_view.rs | 1 + src/saga_manager.rs | 2 ++ src/view.rs | 1 + 4 files changed, 11 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 6dedbb7..ee6b8e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. @@ -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. diff --git a/src/materialized_view.rs b/src/materialized_view.rs index f3c550d..052d677 100644 --- a/src/materialized_view.rs +++ b/src/materialized_view.rs @@ -46,6 +46,7 @@ where Repository: ViewStateRepository, View: ViewStateComputation, { + /// Creates a new instance of [MaterializedView]. pub fn new(repository: Repository, view: View) -> Self { MaterializedView { repository, diff --git a/src/saga_manager.rs b/src/saga_manager.rs index 4ec899f..6a8498c 100644 --- a/src/saga_manager.rs +++ b/src/saga_manager.rs @@ -12,6 +12,7 @@ use crate::saga::Saga; /// - `Error` - error #[async_trait] pub trait ActionPublisher { + /// 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, Error>; } @@ -38,6 +39,7 @@ impl<'a, A, AR, Publisher, Error> SagaManager<'a, A, AR, Publisher, Error> where Publisher: ActionPublisher, { + /// Creates a new instance of [SagaManager]. pub fn new(action_publisher: Publisher, saga: Saga<'a, AR, A>) -> Self { SagaManager { action_publisher, diff --git a/src/view.rs b/src/view.rs index 491e1d9..50aa8f4 100644 --- a/src/view.rs +++ b/src/view.rs @@ -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 { /// Computes new state based on the current state and the events. fn compute_new_state(&self, current_state: Option, events: &[&E]) -> S;