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")]
32#[doc(no_inline)]
33pub use rand;
34#[cfg(feature = "rand")]
35#[doc(no_inline)]
36pub use rand_distr;
37
38#[macro_use]
39pub(crate) mod macros {
40    #[macro_use]
41    pub mod gsw;
42    #[macro_use]
43    pub mod seal;
44    #[macro_use]
45    pub mod wrapper;
46}
47
48#[doc(inline)]
49pub use self::{
50    error::*,
51    id::Id,
52    state::{NState, State, StateBase, StateRepr, Stateful},
53    time::{Now, RawTimestamp, Timestamp},
54    types::prelude::*,
55};
56
57pub mod error;
58pub mod id;
59pub mod state;
60pub mod time;
61
62pub mod types {
63    #[doc(inline)]
64    pub use self::prelude::*;
65
66    pub mod direction;
67
68    pub(crate) mod prelude {
69        #[allow(unused_imports)]
70        #[doc(inline)]
71        pub use super::aliases::*;
72        #[doc(inline)]
73        pub use super::direction::*;
74    }
75
76    pub(crate) mod aliases {
77        #[cfg(feature = "alloc")]
78        /// Type alias for a boxed error with send, sync, and static flags enabled
79        pub type BoxError = alloc::boxed::Box<dyn core::error::Error + Send + Sync + 'static>;
80        #[cfg(feature = "alloc")]
81        /// Type alias for the standard result used
82        pub type BoxResult<T = ()> = core::result::Result<T, BoxError>;
83        #[cfg(feature = "std")]
84        /// Type alias wrapping a locked, thread-safe structure with a [Mutex] in an [Arc]
85        pub type Arcm<T> = std::sync::Arc<std::sync::Mutex<T>>;
86        #[cfg(feature = "std")]
87        /// Type alias for [std::io::Result]
88        pub type IOResult<T = ()> = std::io::Result<T>;
89    }
90}
91
92pub mod prelude {
93    #[doc(no_inline)]
94    pub use crate::error::*;
95    #[doc(no_inline)]
96    pub use crate::id::prelude::*;
97    #[doc(no_inline)]
98    pub use crate::state::prelude::*;
99    #[doc(no_inline)]
100    pub use crate::time::prelude::*;
101    #[doc(no_inline)]
102    pub use crate::types::prelude::*;
103}