-
Notifications
You must be signed in to change notification settings - Fork 11
/
lib.rs
31 lines (29 loc) · 1.17 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use async_trait::async_trait;
pub use configuration::{NetworkConfig, NetworkConfigBuilder, RegistrationStrategy};
pub use orchestrator::{errors::OrchestratorError, network::Network, AddNodeOpts, Orchestrator};
use provider::NativeProvider;
use support::{fs::local::LocalFileSystem, process::os::OsProcessManager};
#[async_trait]
pub trait NetworkConfigExt {
/// Spawns a network using the native provider.
///
/// # Example:
/// ```rust
/// # use zombienet_sdk::{NetworkConfig, NetworkConfigExt};
/// # async fn example() -> Result<(), zombienet_sdk::OrchestratorError> {
/// let network = NetworkConfig::load_from_toml("config.toml")?
/// .spawn_native()
/// .await?;
/// # Ok(())
/// # }
/// ```
async fn spawn_native(self) -> Result<Network<LocalFileSystem>, OrchestratorError>;
}
#[async_trait]
impl NetworkConfigExt for NetworkConfig {
async fn spawn_native(self) -> Result<Network<LocalFileSystem>, OrchestratorError> {
let provider = NativeProvider::new(LocalFileSystem {}, OsProcessManager {});
let orchestrator = Orchestrator::new(LocalFileSystem {}, provider);
orchestrator.spawn(self).await
}
}