Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ homepage = "https://github.com/scattered-systems/scsys/wiki"
keywords = ["blockchain", "primitives", "scsys"]
license = "Apache-2.0"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.38"
version = "0.1.39"

[profile.dev]
codegen-units = 256
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,41 @@
[![Clippy](https://github.com/Scattered-Systems/scsys/actions/workflows/clippy.yml/badge.svg)](https://github.com/Scattered-Systems/scsys/actions/workflows/clippy.yml)
[![Rust](https://github.com/Scattered-Systems/scsys/actions/workflows/rust.yml/badge.svg)](https://github.com/Scattered-Systems/scsys/actions/workflows/rust.yml)

***

Welcome to scsys, this crate was created in support of the Scattered-Systems ecosystem. The crate is reserved primarily for implementing a variety of critical primitives and utilities.

## Getting Started

Use Rust's built-in package manager [crates](https://crates.io/crates/scsys) to install *scsys*.

### Building from the source

#### *Clone the repository*

```bash
git clone https://github.com/scattered-systems/scsys
cd scsys
```

#### *Build the workspace locally*

```bash
cargo xtask build
```

or

```bash
cargo xtask build --release
```

#### *Auto*

Automatically format and analyze the codebase before building then testing.

```bash
cargo install package
cargo xtask auto
```

## Usage
Expand Down
6 changes: 3 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This section is used to update intrested parties as to which versions are curren

| Package | Current | Supported |
|---------|---------|-----------|
| scsys | 0.1.33 | <=0.1.30 |
| scsys | 0.1.39 | <=0.1.30 |

## Reporting a Vulnerability

Expand All @@ -16,5 +16,5 @@ for more information.

### _GitHub_

* [Company](https://github.com/scattered-systems)
* [Creator](https://github.com/FL03)
- [Company](https://github.com/scattered-systems)
- [Creator](https://github.com/FL03)
6 changes: 3 additions & 3 deletions actors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["core", "primitives", "scsys"]
license = "Apache-2.0"
name = "scsys-actors"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.38" # TODO: Update the package version
version = "0.1.39" # TODO: Update the package version

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -22,8 +22,8 @@ bson = { features = ["chrono-0_4", "serde_with", "uuid-0_8"], version = "2.4.0"
chrono = "0.4.22"
config = "0.13.2"
glob = "0.3.0"
serde = { features = ["derive"], version = "1.0.148" }
serde_json = "1.0.89"
serde = { features = ["derive"], version = "1" }
serde_json = "1"
strum = { features = ["derive"], version = "0.24.1" }
url = "2.3.1"

Expand Down
5 changes: 5 additions & 0 deletions actors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ pub mod agents;
pub mod catalysts;
pub mod contexts;
pub mod handlers;
pub mod loggers;
pub mod messages;
pub mod networking;
pub mod providers;
pub mod sessions;
pub mod states;

pub(crate) mod direction;
pub(crate) mod justify;

pub type Job = Box<dyn FnOnce() + Send + 'static>;

pub trait Temporal {}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Description:
... Summary ...
*/
use crate::extract::Extractor;
use serde::{Deserialize, Serialize};
use std::str::FromStr;

#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Server {
Expand All @@ -21,8 +21,7 @@ impl Server {
std::net::SocketAddr::from(self.pieces())
}
pub fn pieces(&self) -> ([u8; 4], u16) {
let host: [u8; 4] = Extractor::new('.', self.host.clone(), None)
.extract()
let host: [u8; 4] = extractor('.', &self.host.clone(), None)
.try_into()
.ok()
.unwrap();
Expand All @@ -45,3 +44,23 @@ impl std::fmt::Display for Server {
)
}
}

const DEFAULT_IGNORE_CHARS: &[char] = &['[', ']', ',', '.', ' '];

/// Implements the basic algorithm used by the extractor
fn extractor<S: ToString, T: FromStr + ToString>(
bp: char,
data: &S,
exclude: Option<&[char]>,
) -> Vec<T>
where
<T as FromStr>::Err: std::fmt::Debug,
{
let data = data.to_string();
let skip = exclude.unwrap_or(DEFAULT_IGNORE_CHARS);
let trimmed: &str = data.trim_matches(skip);
trimmed
.split(bp)
.map(|i| i.trim_matches(skip).parse::<T>().unwrap())
.collect()
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Description:
... Summary ...
*/
use crate::Result;

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
Expand Down
15 changes: 15 additions & 0 deletions actors/src/states/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ pub(crate) mod specs {
use crate::messages::Message;
use std::sync::Arc;

pub trait Eventful: Clone + Default + ToString {
type Event: Clone + Default + ToString;

fn by_arc(self: Arc<Self>) -> Arc<Self> {
self
}
fn event(&self) -> Self::Event
where
Self: Sized;
fn timestamp(self) -> i64;
fn now(self) -> i64 {
chrono::Utc::now().timestamp()
}
}

pub trait StatePack: Default + ToString {}

pub trait Stateful<S: StatePack>: Clone + Default {
Expand Down
16 changes: 11 additions & 5 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@ keywords = ["core", "primitives", "scsys"]
license = "Apache-2.0"
name = "scsys-core"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.38" # TODO: Update the package version
version = "0.1.39" # TODO: Update the package version

[features]
default = []
# wasm = ["wasm-bindgen/serde-serialize"]

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

[dependencies]
bson = { features = ["chrono-0_4", "serde_with", "uuid-0_8"], version = "2.4.0" }
anyhow = "1.0.68"
bson = { features = ["chrono-0_4", "uuid-0_8"], version = "2.4.0" }
chrono = "0.4.22"
config = "0.13.2"
glob = "0.3.0"
nom = "7.1.1"
serde = { features = ["derive"], version = "1.0.148" }
serde_json = "1.0.89"
serde = { features = ["derive"], version = "1" }
serde_json = "1"
strum = { features = ["derive"], version = "0.24.1" }
url = "2.3.1"

# wasm-bindgen = { features = ["serde-serialize"], optional = true, version = "0.2.83" }

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
48 changes: 0 additions & 48 deletions core/src/events/event.rs

This file was deleted.

10 changes: 0 additions & 10 deletions core/src/events/misc/mod.rs

This file was deleted.

17 changes: 0 additions & 17 deletions core/src/events/misc/payload.rs

This file was deleted.

31 changes: 0 additions & 31 deletions core/src/events/misc/variants.rs

This file was deleted.

32 changes: 0 additions & 32 deletions core/src/events/mod.rs

This file was deleted.

4 changes: 2 additions & 2 deletions core/src/extract/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Description:
... Summary ...
*/
use crate::{extract::base_extractor, DEFAULT_IGNORE_CHARS};
use crate::{extract::extractor, DEFAULT_IGNORE_CHARS};
use std::str::FromStr;

/// Implements the formal interface for operating the extraction features
Expand All @@ -28,6 +28,6 @@ impl<'a> Extractor<'a> {
where
<T as FromStr>::Err: std::fmt::Debug,
{
base_extractor::<String, T>(self.breakpoint, &self.data, Some(self.exclude))
extractor::<String, T>(self.breakpoint, &self.data, Some(self.exclude))
}
}
Loading