pub struct Hlx {
pub config: Option<HelixConfig>,
pub data: HashMap<String, HashMap<String, Value>>,
pub file_path: Option<PathBuf>,
pub dispatcher: HelixDispatcher,
pub operator_engine: OperatorEngine,
}Fields§
§config: Option<HelixConfig>§data: HashMap<String, HashMap<String, Value>>§file_path: Option<PathBuf>§dispatcher: HelixDispatcher§operator_engine: OperatorEngineImplementations§
Source§impl Hlx
impl Hlx
pub async fn load<P: AsRef<Path>>(path: P) -> Result<Self, HlxError>
pub async fn new() -> Result<Self, HlxError>
pub fn get(&self, section: &str, key: &str) -> Option<&Value>
Sourcepub fn set<T: IntoValue>(&mut self, section: &str, key: &str, value: T)
pub fn set<T: IntoValue>(&mut self, section: &str, key: &str, value: T)
Set a value in a section - automatically converts Rust types to DnaValue
§Examples
// String values
hlx.set("project", "name", "MyProject");
hlx.set("project", "version", String::from("1.0.0"));
// Numeric values
hlx.set("config", "port", 8080);
hlx.set("config", "timeout", 30.5);
// Boolean values
hlx.set("features", "debug", true);
// Explicit DnaValue for complex types
hlx.set("data", "items", DnaValue::Array(vec![
DnaValue::String("item1".to_string()),
DnaValue::String("item2".to_string()),
]));pub fn set_str(&mut self, section: &str, key: &str, value: &str)
pub fn set_num(&mut self, section: &str, key: &str, value: f64)
pub fn set_bool(&mut self, section: &str, key: &str, value: bool)
Sourcepub fn increase(
&mut self,
section: &str,
key: &str,
amount: f64,
) -> Result<f64, HlxError>
pub fn increase( &mut self, section: &str, key: &str, amount: f64, ) -> Result<f64, HlxError>
Increase a numeric value by the specified amount If the key doesn’t exist, it will be initialized to 0 + amount If the value is not a number, it will be converted to 0 + amount
pub fn index(&self, section: &str) -> Option<&HashMap<String, Value>>
pub fn index_mut( &mut self, section: &str, ) -> Option<&mut HashMap<String, Value>>
pub async fn server(&mut self) -> Result<(), HlxError>
pub async fn watch(&mut self) -> Result<(), HlxError>
pub async fn process(&mut self) -> Result<(), HlxError>
pub async fn compile(&mut self) -> Result<(), HlxError>
pub async fn execute(&mut self, code: &str) -> Result<Value, HlxError>
pub async fn execute_operator( &self, operator: &str, params: &str, ) -> Result<Value, HlxError>
pub fn sections(&self) -> Vec<&String>
pub fn keys(&self, section: &str) -> Option<Vec<&String>>
pub fn save(&self) -> Result<(), HlxError>
Sourcepub fn make(&self) -> Result<String, HlxError>
pub fn make(&self) -> Result<String, HlxError>
Generate HLX content as a string without writing to file
§Example
let mut hlx = Hlx::new().await?;
hlx.set("project", "name", Value::String("MyProject".to_string()));
hlx.set("project", "version", Value::String("1.0.0".to_string()));
let content = hlx.make()?;
println!("Generated HLX content:\n{}", content);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hlx
impl RefUnwindSafe for Hlx
impl Send for Hlx
impl Sync for Hlx
impl Unpin for Hlx
impl UnwindSafe for Hlx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more