mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-21 14:37:56 +01:00
Restructure
This commit is contained in:
parent
a336f83e75
commit
0cca818cc1
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -616,6 +616,7 @@ dependencies = [
|
|||||||
"erased-serde",
|
"erased-serde",
|
||||||
"futures-signals",
|
"futures-signals",
|
||||||
"futures-test",
|
"futures-test",
|
||||||
|
"intmap",
|
||||||
"inventory",
|
"inventory",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
@ -1025,6 +1026,12 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"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]]
|
[[package]]
|
||||||
name = "inventory"
|
name = "inventory"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
@ -1692,6 +1699,10 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sdk"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "seahash"
|
name = "seahash"
|
||||||
version = "4.1.0"
|
version = "4.1.0"
|
||||||
|
15
Cargo.toml
15
Cargo.toml
@ -7,19 +7,27 @@ authors = [ "dequbed <me@dequbed.space>"
|
|||||||
, "Jannis Rieger <omniskopus@gmail.com>"
|
, "Jannis Rieger <omniskopus@gmail.com>"
|
||||||
]
|
]
|
||||||
license = "LGPL-3.0"
|
license = "LGPL-3.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
debug = true
|
debug = true
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "bffhd/lib.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "bffhd"
|
||||||
|
path = "bin/bffhd/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.101"
|
libc = "0.2.101"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
uuid = { version = "0.8.2", features = ["serde", "v4"] }
|
uuid = { version = "0.8.2", features = ["serde", "v4"] }
|
||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
async-native-tls = "0.3"
|
async-native-tls = "0.3"
|
||||||
|
intmap = "0.7"
|
||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
@ -75,4 +83,7 @@ walkdir = "2.3.2"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
futures-test = "0.3.16"
|
futures-test = "0.3.16"
|
||||||
tempfile = "3.2"
|
tempfile = "3.2"
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = ["modules/*"]
|
||||||
|
32
bffhd/lib.rs
Normal file
32
bffhd/lib.rs
Normal 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 {
|
||||||
|
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
use std::fmt::Debug;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use futures_signals::signal::Mutable;
|
use futures_signals::signal::Mutable;
|
||||||
@ -37,13 +38,14 @@ use crate::db::{
|
|||||||
/// - Validating updates semantically i.e. are the types correct
|
/// - Validating updates semantically i.e. are the types correct
|
||||||
/// - Check authorization of updates i.e. is this user allowed to do that
|
/// - Check authorization of updates i.e. is this user allowed to do that
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Resource {
|
pub trait Resource: Debug {
|
||||||
/// Run whatever internal logic this resource has for the given State update, and return the
|
/// Run whatever internal logic this resource has for the given State update, and return the
|
||||||
/// new output state that this update produces.
|
/// new output state that this update produces.
|
||||||
async fn on_update(&mut self, input: &State) -> Result<State, Error>;
|
async fn on_update(&mut self, input: &State) -> Result<State, Error>;
|
||||||
async fn shutdown(&mut self);
|
async fn shutdown(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Passthrough;
|
pub struct Passthrough;
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Resource for Passthrough {
|
impl Resource for Passthrough {
|
||||||
@ -67,6 +69,7 @@ pub struct Update {
|
|||||||
pub errchan: Sender<Error>,
|
pub errchan: Sender<Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ResourceDriver {
|
pub struct ResourceDriver {
|
||||||
// putput
|
// putput
|
||||||
res: Box<dyn Resource>,
|
res: Box<dyn Resource>,
|
@ -226,7 +226,7 @@ impl<T> SerializeDynOid for T
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn archived_type_oid(&self) -> &'static ObjectIdentifier {
|
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}
|
oiddeser! {$z, $y}
|
||||||
|
|
||||||
impl TypeOid for $z {
|
impl TypeOid for $z {
|
||||||
fn get_type_oid() -> &'static ObjectIdentifier {
|
fn type_oid() -> &'static ObjectIdentifier {
|
||||||
&$x
|
&$x
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_type_name() -> &'static str {
|
fn type_name() -> &'static str {
|
||||||
stringify!($y)
|
stringify!($y)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_type_desc() -> &'static str {
|
fn type_desc() -> &'static str {
|
||||||
"builtin"
|
"builtin"
|
||||||
}
|
}
|
||||||
}
|
}
|
8
modules/sdk/Cargo.toml
Normal file
8
modules/sdk/Cargo.toml
Normal 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
7
modules/sdk/src/lib.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
assert_eq!(2 + 2, 4);
|
||||||
|
}
|
||||||
|
}
|
12
src/lib.rs
12
src/lib.rs
@ -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;
|
|
Loading…
Reference in New Issue
Block a user