Skip to content

Commit

Permalink
Merge pull request #46 from Scattered-Systems/v0.1.40
Browse files Browse the repository at this point in the history
V0.1.40
  • Loading branch information
FL03 authored Jan 3, 2023
2 parents 045c748 + e444b15 commit b8d479c
Show file tree
Hide file tree
Showing 21 changed files with 93 additions and 151 deletions.
2 changes: 1 addition & 1 deletion 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.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
4 changes: 1 addition & 3 deletions actors/src/networking/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ 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,
Expand All @@ -57,7 +55,7 @@ where
<T as FromStr>::Err: std::fmt::Debug,
{
let data = data.to_string();
let skip = exclude.unwrap_or(DEFAULT_IGNORE_CHARS);
let skip = exclude.unwrap_or(&['[', ']', ',', '.', ' ']);
let trimmed: &str = data.trim_matches(skip);
trimmed
.split(bp)
Expand Down
16 changes: 8 additions & 8 deletions core/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-core"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[features]
default = []
Expand All @@ -19,15 +19,15 @@ crate-type = ["cdylib", "rlib"]
test = true

[dependencies]
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"
anyhow = "1"
bson = { features = ["chrono-0_4", "uuid-0_8"], version = "2.4" }
chrono = "0.4"
config = "0.13"
glob = "0.3"
serde = { features = ["derive"], version = "1" }
serde_json = "1"
strum = { features = ["derive"], version = "0.24.1" }
url = "2.3.1"
strum = { features = ["derive"], version = "0.24" }
url = "2.3"

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

Expand Down
52 changes: 0 additions & 52 deletions core/src/accounts/account.rs

This file was deleted.

11 changes: 0 additions & 11 deletions core/src/accounts/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion 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::extractor, DEFAULT_IGNORE_CHARS};
use crate::{extractor, DEFAULT_IGNORE_CHARS};
use std::str::FromStr;

/// Implements the formal interface for operating the extraction features
Expand Down
26 changes: 3 additions & 23 deletions core/src/extract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contrib: FL03 <jo3mccain@icloud.com>
Description: ... Summary ...
*/
pub use self::{extractor::*, files::*, utils::*};
pub use self::{extractor::*, files::*};

mod extractor;
mod files;
Expand All @@ -14,33 +14,13 @@ pub trait Extraction<S: ToString> {
fn extract(bp: char, data: &S, exclude: Option<&[char]>) -> Vec<Self::Res>;
}

pub(crate) mod utils {
use crate::DEFAULT_IGNORE_CHARS;
use std::str::FromStr;

/// Implements the basic algorithm used by the extractor
pub 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()
}
}

#[cfg(test)]
mod tests {
use super::*;

use crate::extractor;

#[test]
fn test_file_extractor() {
let fp = "../README.md";
Expand Down
1 change: 0 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#[doc(inline)]
pub use self::{misc::*, primitives::*, specs::*, utils::*};

pub mod accounts;
pub mod errors;
pub mod extract;

Expand Down
4 changes: 2 additions & 2 deletions core/src/misc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Contrib: FL03 <jo3mccain@icloud.com>
Description: ... Summary ...
*/
pub use self::{appellation::*, ids::*, links::*, timestamp::*,};
pub use self::{appellation::*, ids::*, links::*, timestamp::*};

pub(crate) mod appellation;
pub(crate) mod ids;
pub(crate) mod links;
pub(crate) mod timestamp;
pub(crate) mod timestamp;
1 change: 0 additions & 1 deletion core/src/misc/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ impl TryFrom<&str> for Timestamp {
}
}


#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 0 additions & 2 deletions core/src/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub trait Named {
}
}



pub trait TemporalExt: Temporal {
fn chrono_to_bson(&self, data: ChronoDateTime) -> bson::DateTime {
chrono_into_bson::<Utc>(data)
Expand Down
19 changes: 18 additions & 1 deletion core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contrib: FL03 <jo3mccain@icloud.com>
Description: ... Summary ...
*/
use crate::{BoxResult, ConfigFile, ConfigFileVec};
use crate::{DEFAULT_IGNORE_CHARS, BoxResult, ConfigFile, ConfigFileVec};
use chrono::{DateTime, TimeZone, Utc};
use std::io::{self, BufRead, BufReader};
use std::{fs::File, str::FromStr, string::ToString};
Expand All @@ -21,6 +21,23 @@ pub fn collect_config_files(pattern: &str, required: bool) -> ConfigFileVec {
let f = |p: std::path::PathBuf| ConfigFile::from(p).required(required);
collect_files_as(&f, pattern).expect("Failed to find any similar files...")
}
/// Implements the basic algorithm used by the extractor
pub 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()
}
/// Attempts to collect configuration files, following the given pattern, into a ConfigFileVec
pub fn try_collect_config_files(pattern: &str, required: bool) -> BoxResult<ConfigFileVec> {
let f = |p: std::path::PathBuf| ConfigFile::from(p).required(required);
Expand Down
2 changes: 1 addition & 1 deletion crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["crypto", "scsys"]
license = "Apache-2.0"
name = "scsys-crypto"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[features]
default = []
Expand Down
10 changes: 6 additions & 4 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ keywords = ["derive", "macros", "scsys"]
license = "Apache-2.0"
name = "scsys-derive"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[lib]
proc-macro = true
test = false

[dependencies]
proc-macro2 = "1.0.48"
quote = "1.0.22"
syn = { features = ["full"], version = "1.0.106" }
proc-macro2 = "1"
quote = "1"
syn = { features = ["full"], version = "1" }
serde = { features = ["derive"], version = "1"}
serde_json = "1"

[package.metadata.docs.rs]
all-features = true
Expand Down
10 changes: 0 additions & 10 deletions derive/src/impls/mod.rs

This file was deleted.

31 changes: 26 additions & 5 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
Description:
... Summary ...
*/
pub(crate) mod impls;

extern crate proc_macro;
extern crate quote;
extern crate syn;

use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};

#[proc_macro_derive(Hashable)]
#[proc_macro_derive(Hash)]
pub fn hashable(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = impl_hashable(&ast);
Expand All @@ -25,8 +23,8 @@ fn impl_hashable(ast: &syn::DeriveInput) -> proc_macro2::TokenStream {
let name = &ast.ident;
let res = quote::quote! {
impl Hashable for #name {
fn hash(&self) -> H256 {
scsys::crypto::hasher(&self).into()
fn hash(&self) -> scsys::prelude::H256 {
scsys::prelude::hasher(&self).into()
}
}
};
Expand Down Expand Up @@ -55,3 +53,26 @@ pub(crate) fn impl_named(ast: &syn::DeriveInput) -> proc_macro2::TokenStream {
};
res
}

#[proc_macro_derive(SerdeDisplay)]
pub fn serde_display(input: TokenStream) -> TokenStream {
// Parse the inputs into the proper struct
let ast = parse_macro_input!(input as DeriveInput);

// Build the impl
let gen = impl_serde_display(&ast);

gen.into()
}

pub(crate) fn impl_serde_display(ast: &syn::DeriveInput) -> proc_macro2::TokenStream {
let name = &ast.ident;
let res = quote::quote! {
impl std::fmt::Display for #name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", scsys::prelude::fnl_remove(serde_json::to_string(&self).unwrap()))
}
}
};
res
}
2 changes: 1 addition & 1 deletion gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["scsys"]
license = "Apache-2.0"
name = "scsys-gen"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["macros", "scsys"]
license = "Apache-2.0"
name = "scsys-macros"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
8 changes: 7 additions & 1 deletion scsys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"
name = "scsys"
readme = "README.md"
repository = "https://github.com/scattered-systems/scsys"
version = "0.1.39" # TODO: Update the package version
version = "0.1.40" # TODO: Update the package version

[features]
default = [
Expand Down Expand Up @@ -50,6 +50,12 @@ config = ["config/default"]
crate-type = ["cdylib", "rlib"]
test = true

[build-dependencies]

[dev-dependencies]
serde = { features = ["derive"], version = "1" }
serde_json = "1"

[dependencies]
bson = { features = ["chrono-0_4", "serde_with", "uuid-0_8"], optional = true, version = "2.4.0" }
chrono = { optional = true, version = "0.4.22" }
Expand Down
2 changes: 1 addition & 1 deletion scsys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod prelude {
pub use super::gen::*;
pub use super::*;
#[cfg(feature = "core")]
pub use super::{accounts::*, errors::*, extract::*};
pub use super::{errors::*, extract::*};
// Extras
#[cfg(feature = "bson")]
pub use bson;
Expand Down
Loading

0 comments on commit b8d479c

Please sign in to comment.