Hlx

Struct Hlx 

Source
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: OperatorEngine

Implementations§

Source§

impl Hlx

Source

pub async fn load<P: AsRef<Path>>(path: P) -> Result<Self, HlxError>

Source

pub async fn new() -> Result<Self, HlxError>

Source

pub fn get(&self, section: &str, key: &str) -> Option<&Value>

Source

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()),
]));
Source

pub fn set_str(&mut self, section: &str, key: &str, value: &str)

Source

pub fn set_num(&mut self, section: &str, key: &str, value: f64)

Source

pub fn set_bool(&mut self, section: &str, key: &str, value: bool)

Source

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

Source

pub fn index(&self, section: &str) -> Option<&HashMap<String, Value>>

Source

pub fn index_mut( &mut self, section: &str, ) -> Option<&mut HashMap<String, Value>>

Source

pub async fn server(&mut self) -> Result<(), HlxError>

Source

pub async fn watch(&mut self) -> Result<(), HlxError>

Source

pub async fn process(&mut self) -> Result<(), HlxError>

Source

pub async fn compile(&mut self) -> Result<(), HlxError>

Source

pub async fn execute(&mut self, code: &str) -> Result<Value, HlxError>

Source

pub async fn execute_operator( &self, operator: &str, params: &str, ) -> Result<Value, HlxError>

Source

pub fn sections(&self) -> Vec<&String>

Source

pub fn keys(&self, section: &str) -> Option<Vec<&String>>

Source

pub fn save(&self) -> Result<(), HlxError>

Source

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§

Source§

impl Index<&str> for Hlx

Source§

type Output = HashMap<String, Value>

The returned type after indexing.
Source§

fn index(&self, section: &str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<&str> for Hlx

Source§

fn index_mut(&mut self, section: &str) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> JsonSchemaMaybe for T