mahf/component.rs
1//! Base utilities for `components`, `conditions`, and `lens`es.
2
3use trait_set::trait_set;
4
5trait_set! {
6 /// Collection of traits required by every component.
7 ///
8 /// # Requirements
9 ///
10 /// The [`dyn_clone::DynClone`] and [`erased_serde::Serialize`] traits are automatically
11 /// implemented for [`Component`]s and [`Condition`]s that implement [`Clone`] and
12 /// [`serde::Serialize`].
13 ///
14 /// [`Component`]: crate::components::Component
15 /// [`Condition`]: crate::conditions::Condition
16 pub trait AnyComponent = dyn_clone::DynClone + erased_serde::Serialize + Send + Sync;
17}
18
19/// The result type for fallible execution.
20///
21/// Note that methods returning this type are considered 'application code', and the caller
22/// is expected to only care about if it is an error or not, and not about handling different
23/// errors in a different way.
24/// This is also the reason an [`eyre::Result`] is used instead of a custom error type.
25pub type ExecResult<T> = eyre::Result<T>;