use crate::inventory::elements::Node;
use crate::inventory::value::Value;
use crate::python::value;
use pyo3::prelude::*;
#[pyclass(name = "Node", unsendable)]
pub struct PyNode {
node: Node,
}
impl PyNode {
pub fn new(node: Node) -> Self {
Self { node }
}
}
#[pymethods]
impl PyNode {
#[getter]
fn name(&self) -> String {
self.node.name().to_string()
}
#[getter]
fn classes(&self) -> Vec<String> {
self.node.classes().clone()
}
#[getter]
fn applications(&self) -> Vec<String> {
self.node.applications().as_list().to_vec()
}
#[getter]
fn environment(&self) -> String {
self.node.environment().to_string()
}
#[getter]
fn parameters(&self, py: Python<'_>) -> PyResult<PyObject> {
value::value_to_py(
&Value::Hash(std::rc::Rc::new(self.node.parameters().clone())),
py,
)
}
#[getter]
fn exports(&self, py: Python<'_>) -> PyResult<PyObject> {
value::value_to_py(
&Value::Hash(std::rc::Rc::new(self.node.exports().clone())),
py,
)
}
}