Restructure

This commit is contained in:
Nadja Reitzenstein 2021-10-27 23:20:35 +02:00
parent a336f83e75
commit 0cca818cc1
29 changed files with 79 additions and 19 deletions

11
Cargo.lock generated
View File

@ -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"

View File

@ -7,19 +7,27 @@ authors = [ "dequbed <me@dequbed.space>"
, "Jannis Rieger <omniskopus@gmail.com>"
]
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"
bincode = "1.3"
[workspace]
members = ["modules/*"]

32
bffhd/lib.rs Normal file
View File

@ -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<ResourceDriver>,
initiators: IntMap<InitiatorDriver>,
actors: IntMap<ActorDriver>,
}
#[derive(Debug)]
struct Accountant {
}

View File

@ -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<State, Error>;
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<Error>,
}
#[derive(Debug)]
pub struct ResourceDriver {
// putput
res: Box<dyn Resource>,

View File

@ -226,7 +226,7 @@ impl<T> SerializeDynOid for T
}
fn archived_type_oid(&self) -> &'static ObjectIdentifier {
Archived::<T>::get_type_oid()
Archived::<T>::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"
}
}

8
modules/sdk/Cargo.toml Normal file
View File

@ -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]

7
modules/sdk/src/lib.rs Normal file
View File

@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

View File

@ -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;