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#![cfg_attr(all(feature = "alloc", feature = "nightly"), feature(allocator_api))]
24#![doc(
25 html_logo_url = "https://raw.githubusercontent.com/scattered-systems/.github/main/assets/logo.png",
26 html_favicon_url = "https://raw.githubusercontent.com/scattered-systems/.github/main/assets/favicon.ico"
27)]
28#![crate_type = "lib"]
29
30#[cfg(feature = "alloc")]
31extern crate alloc;
32// re-import the `rand` & `rand_distr` crates if the `rand` feature is enabled
33#[cfg(feature = "rand")]
34pub use rand;
35#[cfg(feature = "rand")]
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 #[macro_use]
47 pub mod wrapper_ops;
48}
49
50#[doc(inline)]
51pub use self::{
52 error::*,
53 id::Id,
54 state::{NState, State, StateBase, StateRepr, Stateful},
55 time::{Now, RawTimestamp, Timestamp},
56 types::prelude::*,
57};
58
59/// this module implements a set of traits and utilities for working with containers
60pub mod cont;
61/// this module implements various error-handling primitives and utilities
62pub mod error;
63/// this module defines the generic [`Id`] wrapper and its implementations
64pub mod id;
65/// this module provides a set of states for state-related workloads ([`State`] & [`NState`])
66pub mod state;
67/// a temporal module establishing a core set of time-related primitives and utilities such as
68/// [`Timestamp`]
69pub mod time;
70
71pub mod types {
72 #[doc(inline)]
73 pub use self::prelude::*;
74
75 /// this module implements the [`LinearDirection`], an enumeration over all possible
76 /// movements in one-dimensional space.
77 pub mod direction;
78 pub mod stages;
79
80 pub(crate) mod prelude {
81 #[allow(unused_imports)]
82 #[doc(inline)]
83 pub use super::aliases::*;
84 #[doc(inline)]
85 pub use super::direction::*;
86 #[doc(inline)]
87 pub use super::stages::*;
88 }
89
90 pub(crate) mod aliases {
91 #[cfg(feature = "alloc")]
92 /// Type alias for a boxed error with send, sync, and static flags enabled
93 pub type BoxError = alloc::boxed::Box<dyn core::error::Error + Send + Sync + 'static>;
94 #[cfg(feature = "alloc")]
95 /// Type alias for the standard result used
96 pub type BoxResult<T = ()> = core::result::Result<T, BoxError>;
97 }
98}
99
100#[doc(hidden)]
101pub mod prelude {
102 pub use crate::error::*;
103
104 pub use crate::cont::prelude::*;
105 pub use crate::id::prelude::*;
106 pub use crate::state::prelude::*;
107 pub use crate::time::prelude::*;
108 pub use crate::types::prelude::*;
109}