diff --git a/Cargo.lock b/Cargo.lock index 1ef3ff3..15828b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -616,6 +616,7 @@ dependencies = [ "erased-serde", "futures-signals", "futures-test", + "intmap", "inventory", "lazy_static", "libc", @@ -1025,6 +1026,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "intmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e50930385956f6c4a0b99f3dd654adcc40788456c36e17c5b20e1d1ceb523ec6" + [[package]] name = "inventory" version = "0.1.10" @@ -1692,6 +1699,10 @@ dependencies = [ "winapi", ] +[[package]] +name = "sdk" +version = "0.1.0" + [[package]] name = "seahash" version = "4.1.0" diff --git a/Cargo.toml b/Cargo.toml index fa00a97..9c622e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,19 +7,27 @@ authors = [ "dequbed " , "Jannis Rieger " ] license = "LGPL-3.0" -edition = "2018" +edition = "2021" [profile.release] opt-level = 3 debug = true lto = "thin" +[lib] +path = "bffhd/lib.rs" + +[[bin]] +name = "bffhd" +path = "bin/bffhd/main.rs" + [dependencies] libc = "0.2.101" lazy_static = "1.4.0" uuid = { version = "0.8.2", features = ["serde", "v4"] } async-trait = "0.1.51" async-native-tls = "0.3" +intmap = "0.7" # Runtime smol = "1.2.5" @@ -75,4 +83,7 @@ walkdir = "2.3.2" [dev-dependencies] futures-test = "0.3.16" tempfile = "3.2" -bincode = "1.3" \ No newline at end of file +bincode = "1.3" + +[workspace] +members = ["modules/*"] diff --git a/src/config.rs b/bffhd/config.rs similarity index 100% rename from src/config.rs rename to bffhd/config.rs diff --git a/src/db.rs b/bffhd/db.rs similarity index 100% rename from src/db.rs rename to bffhd/db.rs diff --git a/src/db/fix.rs b/bffhd/db/fix.rs similarity index 100% rename from src/db/fix.rs rename to bffhd/db/fix.rs diff --git a/src/db/hash.rs b/bffhd/db/hash.rs similarity index 100% rename from src/db/hash.rs rename to bffhd/db/hash.rs diff --git a/src/db/pass.rs b/bffhd/db/pass.rs similarity index 100% rename from src/db/pass.rs rename to bffhd/db/pass.rs diff --git a/src/db/raw.rs b/bffhd/db/raw.rs similarity index 100% rename from src/db/raw.rs rename to bffhd/db/raw.rs diff --git a/src/db/resources.rs b/bffhd/db/resources.rs similarity index 100% rename from src/db/resources.rs rename to bffhd/db/resources.rs diff --git a/src/db/state.rs b/bffhd/db/state.rs similarity index 100% rename from src/db/state.rs rename to bffhd/db/state.rs diff --git a/src/db/typed.rs b/bffhd/db/typed.rs similarity index 100% rename from src/db/typed.rs rename to bffhd/db/typed.rs diff --git a/src/db/user.rs b/bffhd/db/user.rs similarity index 100% rename from src/db/user.rs rename to bffhd/db/user.rs diff --git a/src/error.rs b/bffhd/error.rs similarity index 100% rename from src/error.rs rename to bffhd/error.rs diff --git a/bffhd/lib.rs b/bffhd/lib.rs new file mode 100644 index 0000000..e662035 --- /dev/null +++ b/bffhd/lib.rs @@ -0,0 +1,32 @@ +#![forbid(unused_imports)] + +pub mod config; +pub mod db; +pub mod error; +pub mod network; +pub mod oid; +pub mod permissions; +pub mod resource; +pub mod schema; +pub mod state; +pub mod varint; + +use intmap::IntMap; +use resource::ResourceDriver; + +#[derive(Debug)] +struct InitiatorDriver; +#[derive(Debug)] +struct ActorDriver; + +#[derive(Debug)] +struct System { + resources: IntMap, + initiators: IntMap, + actors: IntMap, +} + +#[derive(Debug)] +struct Accountant { + +} \ No newline at end of file diff --git a/src/network.rs b/bffhd/network.rs similarity index 100% rename from src/network.rs rename to bffhd/network.rs diff --git a/src/oid.rs b/bffhd/oid.rs similarity index 100% rename from src/oid.rs rename to bffhd/oid.rs diff --git a/src/permissions.rs b/bffhd/permissions.rs similarity index 100% rename from src/permissions.rs rename to bffhd/permissions.rs diff --git a/src/resource.rs b/bffhd/resource.rs similarity index 98% rename from src/resource.rs rename to bffhd/resource.rs index a720afc..fa4006c 100644 --- a/src/resource.rs +++ b/bffhd/resource.rs @@ -1,3 +1,4 @@ +use std::fmt::Debug; use async_trait::async_trait; use futures_signals::signal::Mutable; @@ -37,13 +38,14 @@ use crate::db::{ /// - Validating updates semantically i.e. are the types correct /// - Check authorization of updates i.e. is this user allowed to do that #[async_trait] -pub trait Resource { +pub trait Resource: Debug { /// Run whatever internal logic this resource has for the given State update, and return the /// new output state that this update produces. async fn on_update(&mut self, input: &State) -> Result; async fn shutdown(&mut self); } +#[derive(Debug)] pub struct Passthrough; #[async_trait] impl Resource for Passthrough { @@ -67,6 +69,7 @@ pub struct Update { pub errchan: Sender, } +#[derive(Debug)] pub struct ResourceDriver { // putput res: Box, diff --git a/src/schema.rs b/bffhd/schema.rs similarity index 100% rename from src/schema.rs rename to bffhd/schema.rs diff --git a/src/state.rs b/bffhd/state.rs similarity index 100% rename from src/state.rs rename to bffhd/state.rs diff --git a/src/state/value.rs b/bffhd/state/value.rs similarity index 98% rename from src/state/value.rs rename to bffhd/state/value.rs index a4c1ae4..86804ae 100644 --- a/src/state/value.rs +++ b/bffhd/state/value.rs @@ -226,7 +226,7 @@ impl SerializeDynOid for T } fn archived_type_oid(&self) -> &'static ObjectIdentifier { - Archived::::get_type_oid() + Archived::::type_oid() } } @@ -475,15 +475,15 @@ macro_rules! oidvalue { oiddeser! {$z, $y} impl TypeOid for $z { - fn get_type_oid() -> &'static ObjectIdentifier { + fn type_oid() -> &'static ObjectIdentifier { &$x } - fn get_type_name() -> &'static str { + fn type_name() -> &'static str { stringify!($y) } - fn get_type_desc() -> &'static str { + fn type_desc() -> &'static str { "builtin" } } diff --git a/src/varint.rs b/bffhd/varint.rs similarity index 100% rename from src/varint.rs rename to bffhd/varint.rs diff --git a/src/bin/bffhd/main.rs b/bin/bffhd/main.rs similarity index 100% rename from src/bin/bffhd/main.rs rename to bin/bffhd/main.rs diff --git a/connection-state.dot b/docs/connection-state.dot similarity index 100% rename from connection-state.dot rename to docs/connection-state.dot diff --git a/draft-fabaccess-protocol.md b/docs/draft-fabaccess-protocol.md similarity index 100% rename from draft-fabaccess-protocol.md rename to docs/draft-fabaccess-protocol.md diff --git a/state.dot b/docs/state.dot similarity index 100% rename from state.dot rename to docs/state.dot diff --git a/modules/sdk/Cargo.toml b/modules/sdk/Cargo.toml new file mode 100644 index 0000000..7fb36fa --- /dev/null +++ b/modules/sdk/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "sdk" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/modules/sdk/src/lib.rs b/modules/sdk/src/lib.rs new file mode 100644 index 0000000..31e1bb2 --- /dev/null +++ b/modules/sdk/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index b6173c1..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![forbid(unused_imports)] - -pub mod config; -pub mod db; -pub mod error; -pub mod network; -pub mod oid; -pub mod permissions; -pub mod resource; -pub mod schema; -pub mod state; -pub mod varint; \ No newline at end of file