we can now deploy the Blob module

This commit is contained in:
Sebastian Moser
2024-08-31 15:57:44 +02:00
parent a750734fe2
commit 386ff500fc
7 changed files with 152 additions and 18 deletions

View File

@@ -43,6 +43,8 @@ pub mod module;
static MSG_CHANNEL_SIZE: usize = 200;
static BUILD_TIME_CONFIG: &str = include_str!(std::env!("MIZE_BUILD_CONFIG"));
/// The Instance type is the heart of the mize system
#[derive(Clone)]
pub struct Instance {
@@ -141,6 +143,10 @@ impl Instance {
fn init(&mut self) -> MizeResult<()> {
// load the config from build time
let config = ItemData::from_toml(BUILD_TIME_CONFIG)?;
self.set_blocking("0", config);
// platform specific init code
crate::platform::any::instance_init(self);
@@ -166,7 +172,7 @@ impl Instance {
let mut instance = Instance::empty()?;
instance.set_blocking("0", config.clone());
instance.set_blocking("0", config);
instance.init()?;

View File

@@ -1,4 +1,5 @@
use tracing::{debug, error, info, instrument, trace, warn, Instrument};
use serde::Deserialize;
use serde::Serialize;
use core::fmt;
use std::fmt::Debug;
@@ -148,6 +149,16 @@ impl ItemData {
ItemData(CborValue::Null)
}
pub fn from_toml(toml_string: &str) -> MizeResult<ItemData> {
let toml_deserializer = toml::Deserializer::new(&toml_string);
let value = CborValue::deserialize(toml_deserializer)
.mize_result_msg(format!("Could not deserialize the toml string: {}", &toml_string))?;
return Ok(value.into_item_data());
}
pub fn from_string<S: Into<String>>(into_string: S) -> ItemData {
let string = into_string.into();
let data = CborValue::Text(string);

View File

@@ -188,12 +188,9 @@ pub fn config_from_file(file_path: String) -> MizeResult<ItemData> {
let toml_string = fs::read_to_string(&file_path)
.mize_result_msg(format!("Could not read file {} as mize config", &file_path))?;
let toml_deserializer = toml::Deserializer::new(&toml_string.as_str());
let item_data = ItemData::from_toml(toml_string.as_str())?;
let config = CborValue::deserialize(toml_deserializer)
.mize_result_msg(format!("Could not deserialize the content of MIZE_CONFIG_FILE at {}", &file_path))?;
return Ok(config.into_item_data());
return Ok(item_data);
}
fn config_from_string(config_string: String) -> MizeResult<ItemData> {