diff --git a/CHANGELOG.md b/CHANGELOG.md index cd9be00..f3fe3dd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### v0.2.1 +* Runtime - Add support for **Any** state type. * SDK - Use fsio crate for file system apis. * Runtime - Use fsio crate for file system apis. diff --git a/duckscript/src/types/runtime.rs b/duckscript/src/types/runtime.rs index ca2b936..b90d0f6 100644 --- a/duckscript/src/types/runtime.rs +++ b/duckscript/src/types/runtime.rs @@ -9,7 +9,10 @@ mod runtime_test; use crate::types::command::Commands; use crate::types::instruction::Instruction; +use std::any::Any; +use std::cell::RefCell; use std::collections::HashMap; +use std::rc::Rc; /// enum defining what values can be stored in the state map #[derive(Debug, Clone)] @@ -36,6 +39,8 @@ pub enum StateValue { List(Vec), /// sub state value SubState(HashMap), + /// any value + Any(Rc>), } /// The context structure diff --git a/duckscript_sdk/src/utils/state.rs b/duckscript_sdk/src/utils/state.rs index f7f31c7..1d55933 100644 --- a/duckscript_sdk/src/utils/state.rs +++ b/duckscript_sdk/src/utils/state.rs @@ -144,6 +144,7 @@ pub(crate) fn get_as_string(state_value: &StateValue) -> Result StateValue::ByteArray(_) => Err("Unsupported value type.".to_string()), StateValue::List(_) => Err("Unsupported value type.".to_string()), StateValue::SubState(_) => Err("Unsupported value type.".to_string()), + StateValue::Any(_) => Err("Unsupported value type.".to_string()), } } @@ -204,6 +205,10 @@ where state.insert(key, StateValue::List(value)); Err("Invalid handle provided.".to_string()) } + StateValue::Any(value) => { + state.insert(key, StateValue::Any(value)); + Err("Invalid handle provided.".to_string()) + } }, None => Err(format!("Handle: {} not found.", &key).to_string()), } @@ -266,6 +271,10 @@ where state.insert(key, StateValue::SubState(value)); Err("Invalid handle provided.".to_string()) } + StateValue::Any(value) => { + state.insert(key, StateValue::Any(value)); + Err("Invalid handle provided.".to_string()) + } }, None => Err(format!("Handle: {} not found.", &key).to_string()), }