start backend functionality

master
Avril 4 years ago
parent e120cd547d
commit ca989eb51d
Signed by: flanchan
GPG Key ID: 284488987C31F630

39
Cargo.lock generated

@ -235,7 +235,9 @@ dependencies = [
"color-eyre", "color-eyre",
"cryptohelpers", "cryptohelpers",
"futures", "futures",
"generational-arena",
"getrandom 0.2.0", "getrandom 0.2.0",
"jemallocator",
"lazy_static", "lazy_static",
"log", "log",
"pretty_env_logger", "pretty_env_logger",
@ -332,6 +334,12 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "fs_extra"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
[[package]] [[package]]
name = "fuchsia-cprng" name = "fuchsia-cprng"
version = "0.1.1" version = "0.1.1"
@ -449,6 +457,16 @@ dependencies = [
"slab", "slab",
] ]
[[package]]
name = "generational-arena"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601"
dependencies = [
"cfg-if 0.1.10",
"serde",
]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.12.3" version = "0.12.3"
@ -689,6 +707,27 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
name = "jemalloc-sys"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45"
dependencies = [
"cc",
"fs_extra",
"libc",
]
[[package]]
name = "jemallocator"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69"
dependencies = [
"jemalloc-sys",
"libc",
]
[[package]] [[package]]
name = "kernel32-sys" name = "kernel32-sys"
version = "0.2.2" version = "0.2.2"

@ -24,7 +24,9 @@ base64 = "0.13.0"
color-eyre = {version = "0.5", default-features=false} color-eyre = {version = "0.5", default-features=false}
cryptohelpers = {version = "1.5.1", features= ["sha256", "rsa", "serde"]} cryptohelpers = {version = "1.5.1", features= ["sha256", "rsa", "serde"]}
futures = "0.3.8" futures = "0.3.8"
generational-arena = {version = "0.2.8", features= ["serde"]}
getrandom = "0.2.0" getrandom = "0.2.0"
jemallocator = "0.3.2"
lazy_static = "1.4.0" lazy_static = "1.4.0"
log = "0.4.11" log = "0.4.11"
pretty_env_logger = "0.4.0" pretty_env_logger = "0.4.0"

@ -4,6 +4,10 @@
#[macro_use] extern crate log; #[macro_use] extern crate log;
use jemallocator::Jemalloc;
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
use color_eyre::{ use color_eyre::{
eyre::{ eyre::{

@ -1,8 +1,69 @@
//! Server state //! Server state
use super::*; use super::*;
use std::{
collections::HashMap,
};
use generational_arena::{
Arena, Index,
};
#[derive(Debug, Clone)] /// Possible value types of the data map
pub struct ServerState #[derive(Debug, Serialize, Deserialize)]
pub enum Data
{ {
Byte(u8),
Char(char),
Bool(bool),
SI(i64),
UI(u64),
FI(f64),
Text(String),
Binary(Vec<u8>),
/// A reference index to an item within the same `Datamap` as this one.
RelativeRef(Index),
/// A reference to an item N deep within nested `Map` elements.
///
/// The first `Index` specifies the `Map` data item at the root `Datamap` that contains the next, et cetera. The pointed to value is the last index.
AbsoluteRef(Vec<Index>),
List(Vec<Atom>),
Map(Datamap),
Null,
}
/// Information about a map entry.
#[derive(Debug, Serialize, Deserialize)]
pub struct Info
{
created: u64,
modified: u64,
//TODO: Info about who owns it, perms, etc.
}
/// The root data containing map
#[derive(Debug, Serialize, Deserialize)]
pub struct Datamap
{
data: Arena<Atom>,
ident: HashMap<Identifier, Index>,
}
/// A value in a datamap, contains the information about the value and the value itself.
#[derive(Debug, Serialize, Deserialize)]
pub struct Atom(Data, Info);
/// An identifier for an item in a `Datamap`, or an item nested within many `Datamap`s.
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Identifier(String);
/// Contains the state of the whole program
#[derive(Debug)]
pub struct ServerState
{
root: Datamap,
} }

Loading…
Cancel
Save