Skip to content

Commit

Permalink
Merge pull request #3 from FL03/v0.0.2
Browse files Browse the repository at this point in the history
V0.0.2
  • Loading branch information
FL03 authored Jul 29, 2024
2 parents f0ec785 + 3fe71fc commit 17f43e6
Show file tree
Hide file tree
Showing 64 changed files with 2,281 additions and 1,138 deletions.
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: 2

updates:
- package-ecosystem: cargo
directory: /
Expand All @@ -13,3 +12,7 @@ updates:
directory: /rstm
schedule:
interval: weekly
- package-ecosystem: cargo
directory: /rstm-core
schedule:
interval: weekly
36 changes: 36 additions & 0 deletions .github/workflows/crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,45 @@ on:
workflow_dispatch:

jobs:
independents:
env:
CRATE_NAME: ${{ github.event.repository.name }}-${{ matrix.suffix }}
name: Publish (${{ matrix.suffix }})
runs-on: ubuntu-latest
strategy:
matrix:
suffix: [ core ]
steps:
- uses: actions/checkout@v4
- name: cache
uses: actions/cache@v4
with:
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
target/debug
target/release
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
cargo-${{ runner.os }}-
cargo-
- run: cargo publish --all-features -v -p ${{ env.CRATE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish:
name: Publish (${{ github.event.repository.name }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: cache
uses: actions/cache@v4
with:
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
target/release
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
cargo-${{ runner.os }}-
cargo-
- run: cargo publish --all-features -v -p ${{ github.event.repository.name }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
28 changes: 10 additions & 18 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,19 @@ jobs:
- name: cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: cargo-${{ matrix.toolchain }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
target/debug
target/release
bench:
name: Benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup (rustup)
run: rustup default nightly && rustup update
restore-keys: |
cargo-${{ matrix.toolchain }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
cargo-${{ matrix.toolchain }}-${{ runner.os }}-
cargo-${{ matrix.toolchain }}-
cargo-
- name: cargo (bench)
if: matrix.toolchain == 'nightly'
run: cargo bench --features full -v --workspace
test:
name: Test
strategy:
matrix:
toolchain: [ stable, nightly ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup default ${{ matrix.toolchain }} && rustup update
- run: cargo test --features full -v --workspace
- name: cargo test (workspace)[full]
run: cargo test -v --workspace -F full
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
default-members = [
"rstm"
"rstm",
]

exclude = [
Expand All @@ -9,13 +9,17 @@ exclude = [

members = [
"rstm",
"core",
]

resolver = "2"


[workspace.dependencies]
lazy_static = "1"
paste = "1"
smart-default = "0.7"
thiserror = "1"

[workspace.package]
authors = ["Joe McCain III <jo3mccain@icloud.com>",]
Expand All @@ -27,7 +31,7 @@ keywords = [ ]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/FL03/rstm.git"
version = "0.0.1"
version = "0.0.2"

[profile.dev]
opt-level = 0
Expand Down
76 changes: 76 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[package]
authors.workspace = true
build = "build.rs"
categories.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "rstm-core"
readme.workspace = true
repository.workspace = true
version.workspace = true

[features]
default = []

full = [
"default",
"serde",
"tracing",
]

# ********* [FF] Dependencies *********
alloc = [
"serde?/alloc",
]

serde = [
"dep:serde",
]

tracing = [
"dep:tracing",
]

# ********* [FF] Environments *********
# std = [
# "alloc",
# "serde?/std",
# "strum/std",
# ]

[lib]
bench = true
crate-type = ["cdylib", "rlib"]
doctest = false
test = true

[dependencies]
thiserror.workspace = true
paste.workspace = true

[dependencies.serde]
# default-features = false
features = ["derive"]
optional = true
version = "1"

[dependencies.strum]
# default-features = false
features = ["derive"]
version = "0.26"

[dependencies.tracing]
features = []
optional = true
version = "0.1"

[dev-dependencies]
lazy_static.workspace = true
tracing-subscriber = { features = [], version = "0.3" }

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
8 changes: 8 additions & 0 deletions core/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Appellation: build <build>
Contrib: FL03 <jo3mccain@icloud.com>
*/

fn main() {
println!("cargo::rustc-check-cfg=cfg(no_std)");
}
32 changes: 19 additions & 13 deletions rstm/src/error.rs → core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,43 @@
Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, strum::VariantNames, thiserror::Error,
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum FsmError {
#[error("[IndexError] Out of Bounds: {0}")]
IndexOutOfBounds(String),
pub enum Error {
#[error("[IndexError] Out of Bounds: {index} is out of bounds for a length of {len}")]
IndexOutOfBounds { index: usize, len: usize },
#[error("[StateError] Invalid State: {0}")]
InvalidState(String),
#[error("[StateError] State Not Found: {0}")]
StateNotFound(String),
#[error("[StateError] State Not Found")]
StateNotFound,
#[error("Transformation error: {0}")]
TransformationError(String),
#[error("Unknown error: {0}")]
Unknown(String),
}

impl FsmError {
pub fn index_out_of_bounds(err: impl ToString) -> Self {
FsmError::IndexOutOfBounds(err.to_string())
impl Error {
pub fn index_out_of_bounds(index: usize, len: usize) -> Self {
Error::IndexOutOfBounds { index, len }
}

pub fn invalid_state(err: impl ToString) -> Self {
FsmError::InvalidState(err.to_string())
Error::InvalidState(err.to_string())
}

pub fn state_not_found(err: impl ToString) -> Self {
FsmError::StateNotFound(err.to_string())
pub fn state_not_found() -> Self {
Error::StateNotFound
}

pub fn transformation_error(message: impl ToString) -> Self {
FsmError::TransformationError(message.to_string())
Error::TransformationError(message.to_string())
}

pub fn unknown(message: impl ToString) -> Self {
FsmError::Unknown(message.to_string())
Error::Unknown(message.to_string())
}
}

impl From<&str> for Error {
fn from(err: &str) -> Self {
Error::Unknown(err.to_string())
}
}
39 changes: 39 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Appellation: rstm-core <library>
Contrib: FL03 <jo3mccain@icloud.com>
*/
//! # rstm-core
//!
// #![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "alloc")]
extern crate alloc;

#[doc(inline)]
pub use self::{
error::Error, ops::prelude::*, rules::prelude::*, state::State, tape::StdTape,
traits::prelude::*, types::prelude::*,
};

#[macro_use]
pub(crate) mod macros;
#[macro_use]
pub(crate) mod seal;

pub mod error;
pub mod ops;
pub mod rules;
pub mod state;
pub mod tape;
pub mod traits;
pub mod types;

pub mod prelude {
pub use crate::error::Error;
pub use crate::ops::prelude::*;
pub use crate::rules::prelude::*;
pub use crate::state::prelude::*;
pub use crate::tape::prelude::*;
pub use crate::traits::prelude::*;
pub use crate::types::prelude::*;
}
7 changes: 7 additions & 0 deletions core/src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
Appellation: macros <module>
Contrib: FL03 <jo3mccain@icloud.com>
*/

#[macro_use]
pub mod states;
4 changes: 4 additions & 0 deletions core/src/macros/states.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Appellation: states <macros>
Contrib: FL03 <jo3mccain@icloud.com>
*/
17 changes: 17 additions & 0 deletions core/src/ops/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Appellation: ops <module>
Contrib: FL03 <jo3mccain@icloud.com>
*/
//! # Operations
//!
//! Overloadable operations used throughout the `rstm` crate.
#[doc(inline)]
pub use self::transform::*;

#[doc(hidden)]
pub mod shift;
pub mod transform;

pub(crate) mod prelude {
pub use super::transform::*;
}
10 changes: 10 additions & 0 deletions core/src/ops/shift.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Appellation: shift <module>
Contrib: FL03 <jo3mccain@icloud.com>
*/

pub trait Shift<T> {
type Output;

fn shift(&self, tape: &T) -> Self::Output;
}
16 changes: 16 additions & 0 deletions core/src/ops/transform.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Appellation: transform <module>
Contrib: FL03 <jo3mccain@icloud.com>
*/

/// The [`Transform`] trait generically describes objects capable of applying some transformation.
/// From a "rustic" point of view, the trait simply provides an additional reference point for
/// the `map` method, which is a method that applies a function to a value and returns a new value.
///
/// [`Transform::transform`] is a method that takes a reference to `self` and a value of type `T`
/// and returns a value of type [`Transform::Output`].
pub trait Transform<T> {
type Output;

fn transform(&self, delta: T) -> Self::Output;
}
Loading

0 comments on commit 17f43e6

Please sign in to comment.