iridis_runtime_core/
node.rs

1use crate::prelude::{thirdparty::libloading, *};
2
3pub struct DynamicallyLinkedNode {
4    pub handle: Box<dyn Node>,
5
6    #[cfg(not(target_family = "unix"))]
7    pub _library: libloading::Library,
8    #[cfg(target_family = "unix")]
9    pub _library: libloading::os::unix::Library,
10}
11
12pub enum RuntimeNode {
13    StaticallyLinked(Box<dyn Node>),
14    DynamicallyLinked(DynamicallyLinkedNode),
15}
16
17impl RuntimeNode {
18    /// This function will async wait the node termination (either success or error)
19    pub async fn run(self) -> Result<()> {
20        match self {
21            RuntimeNode::StaticallyLinked(node) => node.start().await?,
22            RuntimeNode::DynamicallyLinked(node) => node.handle.start().await?,
23        }
24    }
25}