scsys_core/lib.rs
1/*
2 Appellation: scsys-core <library>
3 Contrib: FL03 <jo3mccain@icloud.com>
4*/
5//! # scsys-core
6//!
7//! Welcome the the scsys-core` crate, the foundational library for the [scsys.io](https://scsys.io)
8//! ecosystem. This crate is primarily focused on establish a set of fundamental types, traits,
9//! and utilities that are used throughout the ecosystem. Doing so allows for a natural
10//! consistency to emerge across the ecosystem, while further streamlining the development
11//! process.
12//!
13//! That being said, the general focus of the crate and its feature-gating make it ideally
14//! suited for use outside of the ecosystem as well providing useful primitives such as:
15//!
16//! - [`Id`](id::Id) - a generic identifier type
17//! - [`State`] and [`StateBase`]: dual approaches w.r.t. state management
18//! - [`Timestamp`] (requires the `time` feature): a generic _timestamp_ type implementing
19//! [`Now`]
20//!
21#![allow(clippy::module_inception)]
22#![cfg_attr(not(feature = "std"), no_std)]
23#![doc(
24 html_logo_url = "https://raw.githubusercontent.com/scattered-systems/.github/main/assets/logo.png",
25 html_favicon_url = "https://raw.githubusercontent.com/scattered-systems/.github/main/assets/favicon.ico"
26)]
27
28#[cfg(feature = "alloc")]
29extern crate alloc;
30// re-import the `rand` & `rand_distr` crates if the `rand` feature is enabled
31#[cfg(feature = "rand")]
32pub use rand;
33#[cfg(feature = "rand")]
34pub use rand_distr;
35
36#[macro_use]
37pub(crate) mod macros {
38 #[macro_use]
39 pub mod gsw;
40 #[macro_use]
41 pub mod seal;
42 #[macro_use]
43 pub mod wrapper;
44}
45
46#[doc(inline)]
47pub use self::{
48 error::*,
49 id::Id,
50 state::{NState, State, StateBase, StateRepr, Stateful},
51 time::{Now, RawTimestamp, Timestamp},
52 types::prelude::*,
53};
54/// this module implements various error-handling primitives and utilities
55pub mod error;
56/// this module defines the generic [`Id`] wrapper and its implementations
57pub mod id;
58/// this module provides a set of states for state-related workloads ([`State`] & [`NState`])
59pub mod state;
60/// a temporal module establishing a core set of time-related primitives and utilities such as
61/// [`Timestamp`]
62pub mod time;
63
64pub mod types {
65 #[doc(inline)]
66 pub use self::prelude::*;
67
68 /// this module implements the [`LinearDirection`], an enumeration over all possible
69 /// movements in one-dimensional space.
70 pub mod direction;
71 pub mod stages;
72
73 pub(crate) mod prelude {
74 #[allow(unused_imports)]
75 #[doc(inline)]
76 pub use super::aliases::*;
77 #[doc(inline)]
78 pub use super::direction::*;
79 #[doc(inline)]
80 pub use super::stages::*;
81 }
82
83 pub(crate) mod aliases {
84 #[cfg(feature = "alloc")]
85 /// Type alias for a boxed error with send, sync, and static flags enabled
86 pub type BoxError = alloc::boxed::Box<dyn core::error::Error + Send + Sync + 'static>;
87 #[cfg(feature = "alloc")]
88 /// Type alias for the standard result used
89 pub type BoxResult<T = ()> = core::result::Result<T, BoxError>;
90 }
91}
92
93#[doc(hidden)]
94pub mod prelude {
95 #[doc(no_inline)]
96 pub use crate::error::*;
97 #[doc(no_inline)]
98 pub use crate::id::prelude::*;
99 #[doc(no_inline)]
100 pub use crate::state::prelude::*;
101 #[doc(no_inline)]
102 pub use crate::time::prelude::*;
103 #[doc(no_inline)]
104 pub use crate::types::prelude::*;
105}