hypertune 0.6.2

Hypertune SDK for type safe configuration
Documentation
use std::sync::Arc;

use parking_lot::RwLock;
use thiserror::Error;

use crate::context::Context;
use crate::expression::*;
use crate::node::Node;
use crate::node::UpdateStep;

#[derive(Debug, Clone)]
pub enum NodePropsType {
    None,
    String,
    Enum { value: String },
    Bool,
    Object { object_type_name: String },
    Int,
    Float,
    Void,
    NotFullyReduced,
    Error,
}

#[derive(Clone)]
pub struct NodeProps {
    pub r#type: NodePropsType,
    pub(crate) context: Arc<RwLock<Context>>,
    pub(crate) expression: Option<Expression>,
    pub(crate) commit_hash: Option<String>,
    pub(crate) parent: Option<Node>,
    pub(crate) step: Option<UpdateStep>,
}

impl std::fmt::Debug for NodeProps {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("NodeProps")
            .field("type", &self.r#type)
            .finish()
    }
}

impl NodeProps {
    #[cfg(test)]
    pub fn get_expression(&self) -> Option<Expression> {
        self.expression.clone()
    }
}

#[derive(Error, Debug)]
pub enum NodePropsError {
    #[error("failed to get field")]
    GetField(NodeProps),
}