MizeIds are now stored in a StringPool for Vec<String>
This commit is contained in:
92
Cargo.lock
generated
92
Cargo.lock
generated
@@ -4,11 +4,11 @@ version = 3
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.21.0"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
|
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gimli 0.28.1",
|
"gimli 0.29.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -107,9 +107,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.85"
|
version = "1.0.86"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "27a4bd113ab6da4cd0f521068a6e2ee1065eab54107266a11835d02c8ec86a37"
|
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ascii"
|
name = "ascii"
|
||||||
@@ -125,7 +125,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -226,14 +226,14 @@ dependencies = [
|
|||||||
"heck 0.4.1",
|
"heck 0.4.1",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
version = "0.3.71"
|
version = "0.3.72"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d"
|
checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"addr2line",
|
"addr2line",
|
||||||
"cc",
|
"cc",
|
||||||
@@ -323,9 +323,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.97"
|
version = "1.0.98"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
|
checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
@@ -448,9 +448,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.4.0"
|
version = "1.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa"
|
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
@@ -476,9 +476,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.19"
|
version = "0.8.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crunchy"
|
name = "crunchy"
|
||||||
@@ -692,9 +692,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.14"
|
version = "0.2.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c"
|
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -714,9 +714,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gimli"
|
name = "gimli"
|
||||||
version = "0.28.1"
|
version = "0.29.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "half"
|
name = "half"
|
||||||
@@ -934,6 +934,11 @@ dependencies = [
|
|||||||
"hashbrown 0.14.5",
|
"hashbrown 0.14.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "interner"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "git+https://github.com/c2vi/interner#746e7586bb65e2e50ac02140c6414574efb2eb4e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is-terminal"
|
name = "is-terminal"
|
||||||
version = "0.4.12"
|
version = "0.4.12"
|
||||||
@@ -980,9 +985,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.153"
|
version = "0.2.155"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
@@ -1026,9 +1031,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
|
checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
]
|
]
|
||||||
@@ -1058,6 +1063,7 @@ dependencies = [
|
|||||||
"daemonize",
|
"daemonize",
|
||||||
"env_logger 0.10.2",
|
"env_logger 0.10.2",
|
||||||
"home",
|
"home",
|
||||||
|
"interner",
|
||||||
"log",
|
"log",
|
||||||
"nix",
|
"nix",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -1134,9 +1140,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.32.2"
|
version = "0.35.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
|
checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
@@ -1170,7 +1176,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1199,9 +1205,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.82"
|
version = "1.0.84"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
|
checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -1437,7 +1443,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1561,9 +1567,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.64"
|
version = "2.0.66"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f"
|
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1599,22 +1605,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.60"
|
version = "1.0.61"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
|
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.60"
|
version = "1.0.61"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
|
checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1676,9 +1682,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.37.0"
|
version = "1.38.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
|
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2020,7 +2026,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2106,7 +2112,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
@@ -2149,7 +2155,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.64",
|
"syn 2.0.66",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2409,6 +2415,6 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zeroize"
|
name = "zeroize"
|
||||||
version = "1.7.0"
|
version = "1.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
|
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ log = "0.4.20"
|
|||||||
tokio = { version = "1.21.0", features = ["sync"] }
|
tokio = { version = "1.21.0", features = ["sync"] }
|
||||||
ciborium = { version = "0.2.2", default-features = false }
|
ciborium = { version = "0.2.2", default-features = false }
|
||||||
serde = "1.0.203"
|
serde = "1.0.203"
|
||||||
|
interner = { git = "https://github.com/c2vi/interner" }
|
||||||
|
|
||||||
# wasm dependencies
|
# wasm dependencies
|
||||||
wasm-bindgen = { version = "0.2.84", optional = true }
|
wasm-bindgen = { version = "0.2.84", optional = true }
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ in {
|
|||||||
(fenix.packages.${system}.combine [ wasmToolchain osToolchain ])
|
(fenix.packages.${system}.combine [ wasmToolchain osToolchain ])
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export MIZE_CONFIG_FILE=${self}/default-config.toml
|
export MIZE_CONFIG_FILE=${self}/test-config.toml
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
}) // {
|
}) // {
|
||||||
|
|
||||||
############################## SOME GLOBAL OUTPUTS ##############################
|
############################## SOME GLOBAL OUTPUTS ##############################
|
||||||
inherit inputs;
|
inherit inputs self;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,29 @@
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::{fmt::write, hash::Hash};
|
use std::{collections::binary_heap::Iter, fmt::write, hash::Hash};
|
||||||
|
use interner::{shared::SharedPool, Pooled, shared::SharedVecString};
|
||||||
|
use std::collections::hash_map::RandomState;
|
||||||
|
|
||||||
|
use crate::instance::{store::Store, Instance};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
|
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
|
||||||
pub struct MizeId {
|
pub struct MizeId {
|
||||||
path: Vec<String>
|
pub path: SharedVecString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MizeId {
|
impl MizeId {
|
||||||
pub fn store_part(&self) -> &str {
|
pub fn store_part(&self) -> &str {
|
||||||
self.path.first()
|
self.path.iter().nth(0)
|
||||||
.expect("an empty MizeId found, that should absolutely not be possible!!!!").as_str()
|
.expect("an empty MizeId found, that should absolutely not be possible!!!!").as_str()
|
||||||
}
|
}
|
||||||
pub fn as_vec(self) -> Vec<String> {
|
pub fn path(&self) -> SharedVecString {
|
||||||
self.path
|
self.path.clone()
|
||||||
}
|
}
|
||||||
|
//pub fn as_slice(&self) -> u8 {
|
||||||
|
//self.path
|
||||||
|
//}
|
||||||
|
//pub fn as_iter(&self) -> u8 {
|
||||||
|
//self.path.iter()
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for MizeId {
|
impl fmt::Display for MizeId {
|
||||||
@@ -23,12 +32,63 @@ impl fmt::Display for MizeId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Into<String>> From<T> for MizeId {
|
pub trait IntoMizeId<S: Store> {
|
||||||
fn from(value: T) -> Self {
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId;
|
||||||
let string = value.into();
|
}
|
||||||
let path: Vec<String> = string.split("/").map(|v| v.to_owned()).collect();
|
|
||||||
return MizeId { path }
|
impl<S: Store> IntoMizeId<S> for &str {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
instance.id_from_string(self.to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S: Store> IntoMizeId<S> for String {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
instance.id_from_string(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Store> IntoMizeId<S> for &String {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
instance.id_from_string(self.to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Store> IntoMizeId<S> for Vec<String> {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
instance.id_from_vec_string(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Store> IntoMizeId<S> for &[&str] {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
let mut vec: Vec<String> = Vec::new();
|
||||||
|
for i in self {
|
||||||
|
vec.push((*i).to_owned())
|
||||||
|
}
|
||||||
|
instance.id_from_vec_string(vec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Store> IntoMizeId<S> for Vec<&str> {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
let mut vec: Vec<String> = Vec::new();
|
||||||
|
for i in self {
|
||||||
|
vec.push((*i).to_owned())
|
||||||
|
}
|
||||||
|
instance.id_from_vec_string(vec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<S: Store> IntoMizeId<S> for MizeId {
|
||||||
|
fn to_mize_id(self, instance: &Instance<S>) -> MizeId {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// would only work with a global id_pool
|
||||||
|
// for now use Instance::new_id()
|
||||||
|
//impl<T: Into<String>> From<T> for MizeId {
|
||||||
|
//fn from(value: T) -> Self {
|
||||||
|
//let string = value.into();
|
||||||
|
//let path: Vec<String> = string.split("/").map(|v| v.to_owned()).collect();
|
||||||
|
//return MizeId { MIZE_ID_POOL.get(path) }
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ use uuid::Uuid;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use interner::shared::VecStringPool;
|
||||||
|
|
||||||
use crate::error::{MizeError, MizeResult, IntoMizeResult, MizeResultTrait};
|
use crate::error::{MizeError, MizeResult, IntoMizeResult, MizeResultTrait};
|
||||||
use crate::instance::store::Store;
|
use crate::instance::store::Store;
|
||||||
use crate::instance::connection::Connection;
|
use crate::instance::connection::Connection;
|
||||||
use crate::id::MizeId;
|
use crate::id::{IntoMizeId, MizeId};
|
||||||
use crate::instance::subscription::Subscription;
|
use crate::instance::subscription::Subscription;
|
||||||
use crate::item::{Item, ItemData};
|
use crate::item::{Item, ItemData};
|
||||||
use crate::memstore::MemStore;
|
use crate::memstore::MemStore;
|
||||||
@@ -31,6 +32,7 @@ pub struct Instance<S: Store> {
|
|||||||
pub store: S,
|
pub store: S,
|
||||||
peers: Arc<Mutex<Vec<Box<dyn Connection>>>>,
|
peers: Arc<Mutex<Vec<Box<dyn Connection>>>>,
|
||||||
subs: Arc<Mutex<HashMap<MizeId, Subscription>>>,
|
subs: Arc<Mutex<HashMap<MizeId, Subscription>>>,
|
||||||
|
pub id_pool: VecStringPool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,36 +48,73 @@ impl Instance<MemStore> {
|
|||||||
pub fn new() -> MizeResult<Instance<MemStore>> {
|
pub fn new() -> MizeResult<Instance<MemStore>> {
|
||||||
trace!("[ {} ] Instance::new()", "CALL".yellow());
|
trace!("[ {} ] Instance::new()", "CALL".yellow());
|
||||||
|
|
||||||
let memstore = MemStore::new();
|
let store = MemStore::new();
|
||||||
let instance = Instance {store: memstore, peers: Arc::new(Mutex::new(Vec::new())), subs: Arc::new(Mutex::new(HashMap::new())) };
|
let id_pool = VecStringPool::default();
|
||||||
|
let peers = Arc::new(Mutex::new(Vec::new()));
|
||||||
|
let subs = Arc::new(Mutex::new(HashMap::new()));
|
||||||
|
let mut instance = Instance {store, peers, subs, id_pool };
|
||||||
|
|
||||||
|
instance.init();
|
||||||
|
|
||||||
|
return Ok(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init(&mut self) -> MizeResult<()> {
|
||||||
|
|
||||||
// platform specific init code
|
// platform specific init code
|
||||||
if cfg!(feature = "os-target") { // on os platforms
|
if cfg!(feature = "os-target") { // on os platforms
|
||||||
crate::platform::os::os_instance_init(instance.clone())?
|
crate::platform::os::os_instance_init(self)?
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of platform specific init code
|
// end of platform specific init code
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(instance);
|
pub fn with_config(config: ItemData) -> MizeResult<Instance<MemStore>> {
|
||||||
|
let mut instance = Instance::new()?;
|
||||||
|
instance.set("0", config.clone());
|
||||||
|
instance.init()?;
|
||||||
|
|
||||||
|
// set it again, so that the passed config data has presidence over anything the init would set
|
||||||
|
instance.set("0", config);
|
||||||
|
|
||||||
|
Ok(instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Store> Instance<S> {
|
impl<S: Store> Instance<S> {
|
||||||
pub fn new_item(self) -> MizeResult<Item<S>> {
|
pub fn new_item(&self) -> MizeResult<Item<S>> {
|
||||||
let id = self.store.new_id()?;
|
let id = self.id_from_string(self.store.new_id()?);
|
||||||
return Ok(Item {id, instance: self});
|
return Ok(Item {id, instance: self});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get<I: Into<MizeId>>(self, id: I) -> MizeResult<Item<S>> {
|
pub fn get<I: IntoMizeId<S>>(&self, id: I) -> MizeResult<Item<S>> {
|
||||||
return Ok(Item {id: id.into(), instance: self});
|
let id = id.to_mize_id(self);
|
||||||
|
return Ok(Item {id: id.to_mize_id(self), instance: self});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set<I: Into<MizeId>, V: Into<ItemData>>(self, id: I, value: V) -> MizeResult<()> {
|
pub fn set<I: IntoMizeId<S>, V: Into<ItemData>>(&mut self, id: I, value: V) -> MizeResult<()> {
|
||||||
self.store.set(&id.into(), value)
|
let id = id.to_mize_id(self);
|
||||||
|
self.store.set(id, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_id<T: IntoMizeId<S>>(&self, value: T) -> MizeId {
|
||||||
|
value.to_mize_id(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id_from_string(&self, string: String) -> MizeId {
|
||||||
|
let vec_string: Vec<String> = string.split("/").map(|v| v.to_owned()).collect();
|
||||||
|
return MizeId { path: self.id_pool.get(vec_string) };
|
||||||
|
}
|
||||||
|
pub fn id_from_vec_string(&self, vec_string: Vec<String>) -> MizeId {
|
||||||
|
return MizeId { path: self.id_pool.get(vec_string) };
|
||||||
|
}
|
||||||
|
//impl<T: Into<String>> From<T> for MizeId {
|
||||||
|
//fn from(value: T) -> Self {
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Store> fmt::Debug for Instance<S> {
|
impl<S: Store> fmt::Debug for Instance<S> {
|
||||||
|
|||||||
@@ -9,21 +9,17 @@ pub trait Store {
|
|||||||
// is implemented, so that there can be a multithreaded implementation
|
// is implemented, so that there can be a multithreaded implementation
|
||||||
//fn get(self, id: MizeId) -> MizeResult<Item<Self>> where Self: Sized;
|
//fn get(self, id: MizeId) -> MizeResult<Item<Self>> where Self: Sized;
|
||||||
|
|
||||||
fn set<T: Into<ItemData>>(self, id: &MizeId, data: T) -> MizeResult<()>;
|
fn set<T: Into<ItemData>>(&mut self, id: MizeId, data: T) -> MizeResult<()>;
|
||||||
|
|
||||||
// in the future should implement transactions, ....
|
// in the future should implement transactions, ....
|
||||||
|
|
||||||
// funcs to do with links, backlinks
|
// funcs to do with links, backlinks
|
||||||
fn get_links(self, item: Item<Self>) -> MizeResult<Vec<MizeId>> where Self: Sized;
|
fn get_links(&self, item: Item<Self>) -> MizeResult<Vec<MizeId>> where Self: Sized;
|
||||||
|
|
||||||
fn get_backlinks(self, item: Item<Self>) -> MizeResult<Vec<MizeId>> where Self: Sized;
|
fn get_backlinks(&self, item: Item<Self>) -> MizeResult<Vec<MizeId>> where Self: Sized;
|
||||||
|
|
||||||
fn new_id(&self) -> MizeResult<MizeId>;
|
fn new_id(&self) -> MizeResult<String>;
|
||||||
|
|
||||||
fn get_value_raw(&self, id: &MizeId) -> MizeResult<Vec<u8>>;
|
fn get_value_raw(&self, id: MizeId) -> MizeResult<Vec<u8>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// references an item that is stored in a store
|
|
||||||
pub trait StoreRef {
|
|
||||||
// do we need this or is this basically an item
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,30 +13,30 @@ use ciborium::Value as CborValue;
|
|||||||
|
|
||||||
// a item always has to do with a Instance, which takes care of how it is updated
|
// a item always has to do with a Instance, which takes care of how it is updated
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Item<S: Store + Sized> {
|
pub struct Item<'a, S: Store + Sized> {
|
||||||
pub id: MizeId,
|
pub id: MizeId,
|
||||||
pub instance: Instance<S>
|
pub instance: &'a Instance<S>
|
||||||
}
|
}
|
||||||
|
|
||||||
// without an Instance it is not an item, but only the "data of an item"
|
// without an Instance it is not an item, but only the "data of an item"
|
||||||
// and this type for now is just an alias to CborValue
|
// and this type for now is just an alias to CborValue
|
||||||
pub type ItemData = CborValue;
|
pub type ItemData = CborValue;
|
||||||
|
|
||||||
impl<S: Store> Item<S> {
|
impl<S: Store> Item<'_, S> {
|
||||||
pub fn id(&self) -> &MizeId {
|
pub fn id(&self) -> MizeId {
|
||||||
&self.id
|
self.id.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value_raw(&self) -> MizeResult<Vec<u8>> {
|
pub fn value_raw(&self) -> MizeResult<Vec<u8>> {
|
||||||
// this will call from the instance which gets the value from the store
|
// this will call from the instance which gets the value from the store
|
||||||
self.instance.store.get_value_raw(&self.id())
|
self.instance.store.get_value_raw(self.id())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Store> Display for Item<S> {
|
impl<S: Store> Display for Item<'_, S> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self.value_raw() {
|
match self.value_raw() {
|
||||||
Ok(value) => match String::from_utf8(value) {
|
Ok(value) => match String::from_utf8(value.to_owned()) {
|
||||||
Ok(string) => write!(f, "{}", string),
|
Ok(string) => write!(f, "{}", string),
|
||||||
Err(_) => write!(f, "{:?}", self.value_raw()),
|
Err(_) => write!(f, "{:?}", self.value_raw()),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use std::collections::binary_heap::Iter;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::iter::Map;
|
use std::iter::Map;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -14,6 +15,8 @@ pub struct MemStore {
|
|||||||
inner: Arc<Mutex<MemStoreInner>>,
|
inner: Arc<Mutex<MemStoreInner>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type MemStoreId = u64;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MemStoreInner {
|
struct MemStoreInner {
|
||||||
map: HashMap<u64, CborValue>,
|
map: HashMap<u64, CborValue>,
|
||||||
@@ -21,39 +24,43 @@ struct MemStoreInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Store for MemStore {
|
impl Store for MemStore {
|
||||||
fn set<T: Into<ItemData>>(mut self, id: &MizeId, data: T) -> MizeResult<()> {
|
fn set<T: Into<ItemData>>(&mut self, id: MizeId, data: T) -> MizeResult<()> {
|
||||||
let mut inner = self.inner.lock()?;
|
let mut inner = self.inner.lock()?;
|
||||||
|
|
||||||
|
|
||||||
inner.map.insert(id_to_u64(id)?, data.into());
|
inner.map.insert(id_to_u64(id)?, data.into());
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
fn get_links(self, item: Item<Self>) -> MizeResult<Vec<MizeId>> {
|
fn get_links(&self, item: Item<Self>) -> MizeResult<Vec<MizeId>> {
|
||||||
let inner = self.inner.lock()?;
|
let inner = self.inner.lock()?;
|
||||||
|
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
fn get_backlinks(self, item: Item<Self>) -> MizeResult<Vec<MizeId>> {
|
fn get_backlinks(&self, item: Item<Self>) -> MizeResult<Vec<MizeId>> {
|
||||||
let inner = self.inner.lock()?;
|
let inner = self.inner.lock()?;
|
||||||
|
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
fn new_id(&self) -> MizeResult<MizeId> {
|
fn new_id(&self) -> MizeResult<String> {
|
||||||
let inner = self.inner.lock()?;
|
let mut inner = self.inner.lock()?;
|
||||||
|
|
||||||
let id_string = format!("{}", inner.next_id);
|
let id_string = format!("{}", inner.next_id);
|
||||||
return Ok(id_string.into());
|
inner.next_id += 1;
|
||||||
|
return Ok(id_string);
|
||||||
}
|
}
|
||||||
fn get_value_raw(&self, id: &MizeId) -> MizeResult<Vec<u8>> {
|
fn get_value_raw(&self, id: MizeId) -> MizeResult<Vec<u8>> {
|
||||||
let inner = self.inner.lock()?;
|
let inner = self.inner.lock()?;
|
||||||
|
|
||||||
let cbor_val = inner.map.get(&id_to_u64(id)?)
|
let cbor_val = inner.map.get(&id_to_u64(id.clone())?)
|
||||||
.ok_or(MizeError::new()
|
.ok_or(MizeError::new()
|
||||||
.msg(format!("Item with store_part: {}, id: {} does not exist in MemStore", id_to_u64(id)?, id)))?;
|
.msg(format!("Item with store_part: {}, id: {} does not exist in MemStore", id_to_u64(id.clone())?, id)))?;
|
||||||
|
|
||||||
let mut id_without_first = id.clone().as_vec();
|
let path = id.path();
|
||||||
id_without_first.remove(0);
|
let mut id_iter = path.iter();
|
||||||
get_raw_from_cbor(cbor_val.to_owned(), id_without_first)
|
id_iter.next();
|
||||||
|
let id_without_first = id_iter.collect();
|
||||||
|
|
||||||
|
Ok(get_raw_from_cbor(cbor_val, id_without_first)?.to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,34 +71,39 @@ impl MemStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn id_to_u64(id: &MizeId) -> MizeResult<u64> {
|
fn id_to_u64(id: MizeId) -> MizeResult<u64> {
|
||||||
id.store_part()
|
id.store_part()
|
||||||
.parse()
|
.parse()
|
||||||
.mize_result_msg(format!("Could not parse the store_part of mizeid {} into a u64 for the MemStore", id))
|
.mize_result_msg(format!("Could not parse the store_part of mizeid {} into a u64 for the MemStore", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_raw_from_cbor(value: CborValue, mut path: Vec<String>) -> MizeResult<Vec<u8>> {
|
fn get_raw_from_cbor<'a>(value: &'a CborValue, path: Vec<&String>) -> MizeResult<&'a [u8]> {
|
||||||
match value {
|
match value {
|
||||||
CborValue::Bytes(vec) => Ok(vec),
|
CborValue::Bytes(vec) => Ok(&vec[..]),
|
||||||
CborValue::Text(string) => Ok(string.into_bytes()),
|
CborValue::Text(string) => Ok(string.as_bytes()),
|
||||||
CborValue::Map(map) => {
|
CborValue::Map(map) => {
|
||||||
let mut inner_val: CborValue = CborValue::Null;
|
let mut inner_val: &CborValue = &CborValue::Null;
|
||||||
trace!("map: {:?}", map);
|
trace!("map: {:?}", map);
|
||||||
for (key, val) in map.into_iter() {
|
for (key, val) in map.into_iter() {
|
||||||
let first_path_string = path.first()
|
let first_path_string = *path.iter().nth(0)
|
||||||
.ok_or(MizeError::new().msg("get_raw_from_cbor: path is empty"))?;
|
.ok_or(MizeError::new()
|
||||||
|
.msg("get_raw_from_cbor: path is empty"))?;
|
||||||
|
|
||||||
if let CborValue::Text(key_text) = key {
|
if let CborValue::Text(key_text) = key {
|
||||||
if key_text == *first_path_string {
|
if key_text == first_path_string {
|
||||||
inner_val = val
|
inner_val = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if inner_val == CborValue::Null {
|
if inner_val == &CborValue::Null {
|
||||||
return Err(MizeError::new().msg(format!("get_raw_from_cbor: Path {} not Found", path.join("/"))))
|
return Err(MizeError::new()
|
||||||
|
// jesus christ, this is a pfusch...
|
||||||
|
.msg(format!("get_raw_from_cbor: Path {} not Found", path.clone().into_iter().map(|v| v.to_owned()).collect::<Vec<String>>().join("/"))))
|
||||||
}
|
}
|
||||||
path.remove(0);
|
let mut path_iter = path.into_iter();
|
||||||
get_raw_from_cbor(inner_val, path)
|
path_iter.next();
|
||||||
|
let inner_path = path_iter.collect();
|
||||||
|
get_raw_from_cbor(inner_val, inner_path)
|
||||||
},
|
},
|
||||||
_ => Err(MizeError::new().msg("get_raw_from_cbor: value is not Bytes, Text or Map")),
|
_ => Err(MizeError::new().msg("get_raw_from_cbor: value is not Bytes, Text or Map")),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,15 @@ use mize::instance::Instance;
|
|||||||
|
|
||||||
pub fn run(sub_matches: &ArgMatches) -> MizeResult<()> {
|
pub fn run(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||||
|
|
||||||
let instance = Instance::new();
|
// TODO NEXT!!!
|
||||||
|
// - add --system arg
|
||||||
|
// - add --user arg
|
||||||
|
// - --config arg
|
||||||
|
// - to set a location, where there will be a /store and a /sock
|
||||||
|
// - listen for connections on that sock
|
||||||
|
// - msg handeling
|
||||||
|
let instance = Instance::with_config(todo!());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
let instance_path = match sub_matches.get_one::<String>("store") {
|
let instance_path = match sub_matches.get_one::<String>("store") {
|
||||||
Some(a) => PathBuf::from(a),
|
Some(a) => PathBuf::from(a),
|
||||||
|
|||||||
@@ -260,10 +260,10 @@ fn level_from_env(var_name: &str, log_level: LevelFilter) -> (Option<log::LevelF
|
|||||||
|
|
||||||
fn cli_matches() -> clap::ArgMatches {
|
fn cli_matches() -> clap::ArgMatches {
|
||||||
|
|
||||||
let store_arg = Arg::new("store")
|
let folder_arg = Arg::new("folder")
|
||||||
.short('s')
|
.short('f')
|
||||||
.long("store")
|
.long("folder")
|
||||||
.help("The folder used as the Itemstore");
|
.help("The folder the Instance stores all it's data and the socket for connections");
|
||||||
|
|
||||||
let main = Command::new(APPNAME)
|
let main = Command::new(APPNAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
@@ -284,6 +284,7 @@ fn cli_matches() -> clap::ArgMatches {
|
|||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("set the log-level to OFF")
|
.help("set the log-level to OFF")
|
||||||
)
|
)
|
||||||
|
.arg(&folder_arg)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("run")
|
Command::new("run")
|
||||||
.aliases(["r"])
|
.aliases(["r"])
|
||||||
@@ -295,30 +296,29 @@ fn cli_matches() -> clap::ArgMatches {
|
|||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("mount")
|
Command::new("mount")
|
||||||
.aliases(["m"])
|
.aliases(["m"])
|
||||||
.arg(&store_arg)
|
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("get")
|
Command::new("get")
|
||||||
.aliases(["g"])
|
.aliases(["g"])
|
||||||
.arg(&store_arg)
|
.arg(&folder_arg)
|
||||||
.arg(Arg::new("id").help("The id or path to get"))
|
.arg(Arg::new("id").help("The id or path to get"))
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("set")
|
Command::new("set")
|
||||||
.aliases(["s"])
|
.aliases(["s"])
|
||||||
.arg(&store_arg)
|
.arg(&folder_arg)
|
||||||
.arg(Arg::new("id").help("The id or path to set"))
|
.arg(Arg::new("id").help("The id or path to set"))
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("show")
|
Command::new("show")
|
||||||
.aliases(["so"])
|
.aliases(["so"])
|
||||||
.arg(&store_arg)
|
.arg(&folder_arg)
|
||||||
.arg(Arg::new("id").help("The id or path to sub to and show"))
|
.arg(Arg::new("id").help("The id or path to sub to and show"))
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("call")
|
Command::new("call")
|
||||||
.aliases(["c"])
|
.aliases(["c"])
|
||||||
.arg(&store_arg)
|
.arg(&folder_arg)
|
||||||
)
|
)
|
||||||
.arg_required_else_help(true);
|
.arg_required_else_help(true);
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ use crate::instance::Instance;
|
|||||||
use crate::error::{IntoMizeResult, MizeError, MizeResult};
|
use crate::error::{IntoMizeResult, MizeError, MizeResult};
|
||||||
|
|
||||||
|
|
||||||
pub fn os_instance_init<S: Store>(instance: Instance<S>) -> MizeResult<()> {
|
pub fn os_instance_init<S: Store>(instance: &mut Instance<S>) -> MizeResult<()> {
|
||||||
// this is the code, that runs to initialize an Instance on a system with an os present.
|
// this is the code, that runs to initialize an Instance on a system with an os present.
|
||||||
|
|
||||||
// load MIZE_CONFIG_FILE as the instance, which is item 0
|
////// load MIZE_CONFIG_FILE as the instance, which is item 0
|
||||||
let config_file_path = std::env::var("MIZE_CONFIG_FILE")
|
let config_file_path = std::env::var("MIZE_CONFIG_FILE")
|
||||||
.mize_result_msg("Could not get the MIZE_CONFIG_FILE Environment Variable")?;
|
.mize_result_msg("Could not get the MIZE_CONFIG_FILE Environment Variable")?;
|
||||||
|
|
||||||
@@ -24,6 +24,9 @@ pub fn os_instance_init<S: Store>(instance: Instance<S>) -> MizeResult<()> {
|
|||||||
.mize_result_msg(format!("Could not deserialize the content of MIZE_CONFIG_FILE at {}", &config_file_path))?;
|
.mize_result_msg(format!("Could not deserialize the content of MIZE_CONFIG_FILE at {}", &config_file_path))?;
|
||||||
|
|
||||||
instance.set("0", config)?;
|
instance.set("0", config)?;
|
||||||
|
|
||||||
|
////// load config from MIZE_CONFIG env var
|
||||||
|
//TODO
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user