Struct Executor

Source
pub struct Executor<T: Default + BuildParam<P>, P: BuildCmd> {
    pub configs: HashMap<String, T>,
    pub outputs: HashMap<String, Vec<Task<P>>>,
    /* private fields */
}

Fields§

§configs: HashMap<String, T>§outputs: HashMap<String, Vec<Task<P>>>

Implementations§

Source§

impl<T: Default + BuildParam<P>, P: BuildCmd> Executor<T, P>

Source

pub fn get_config_path(&self) -> &str

Source

pub fn get_config_format(&self) -> &ConfigFormat

Source

pub fn get_ns3_path(&self) -> &str

Source

pub fn get_task_concurrent(&self) -> usize

Source

pub fn get_retry_limit(&self) -> u32

Source

pub fn get_configs(&self) -> &HashMap<String, T>

Source

pub fn get_outputs(&self) -> &HashMap<String, Vec<Task<P>>>

Examples found in repository?
examples/simple.rs (line 78)
64async fn main() {
65    // ========== Use toml format as the config file ==========
66    // Use ExecutorBuilder to build your executor.
67    let mut exe: Executor<MyConfig, MyParam> = ExecutorBuilder::new()
68        .config_path("config.toml")
69        .config_format(ConfigFormat::Toml)
70        .ns3_path("ns-allinone-3.33/ns-3.33/")
71        .build()
72        .unwrap();
73
74    // Run your executor.
75    let _ = exe.execute().await.unwrap();
76
77    // Collect your results.
78    let outputs = exe.get_outputs().to_owned();
79
80    // Here I just print all the results, you can do whatever you want with them here.
81    for (_, output) in outputs {
82        for task in output {
83            println!("{}", task.stderr);
84        }
85    }
86
87    // ========== Use ron format as the config file ==========
88    // Use ExecutorBuilder to build your executor.
89    let mut exe: Executor<MyConfig, MyParam> = ExecutorBuilder::new()
90        .config_path("config.ron")
91        .config_format(ConfigFormat::Ron)
92        .ns3_path("ns-allinone-3.33/ns-3.33/")
93        .task_concurrent(4)
94        .retry_limit(2)
95        .build()
96        .unwrap();
97
98    // Run your executor.
99    let _ = exe.execute().await.unwrap();
100
101    // Collect your results.
102    let outputs = exe.get_outputs().to_owned();
103
104    // Here I just print all the results, you can do whatever you want with them here.
105    for (_, output) in outputs {
106        for task in output {
107            println!("{}", task.stderr);
108        }
109    }
110}
Source

pub async fn execute(&mut self) -> Result<(), Error>

Examples found in repository?
examples/simple.rs (line 75)
64async fn main() {
65    // ========== Use toml format as the config file ==========
66    // Use ExecutorBuilder to build your executor.
67    let mut exe: Executor<MyConfig, MyParam> = ExecutorBuilder::new()
68        .config_path("config.toml")
69        .config_format(ConfigFormat::Toml)
70        .ns3_path("ns-allinone-3.33/ns-3.33/")
71        .build()
72        .unwrap();
73
74    // Run your executor.
75    let _ = exe.execute().await.unwrap();
76
77    // Collect your results.
78    let outputs = exe.get_outputs().to_owned();
79
80    // Here I just print all the results, you can do whatever you want with them here.
81    for (_, output) in outputs {
82        for task in output {
83            println!("{}", task.stderr);
84        }
85    }
86
87    // ========== Use ron format as the config file ==========
88    // Use ExecutorBuilder to build your executor.
89    let mut exe: Executor<MyConfig, MyParam> = ExecutorBuilder::new()
90        .config_path("config.ron")
91        .config_format(ConfigFormat::Ron)
92        .ns3_path("ns-allinone-3.33/ns-3.33/")
93        .task_concurrent(4)
94        .retry_limit(2)
95        .build()
96        .unwrap();
97
98    // Run your executor.
99    let _ = exe.execute().await.unwrap();
100
101    // Collect your results.
102    let outputs = exe.get_outputs().to_owned();
103
104    // Here I just print all the results, you can do whatever you want with them here.
105    for (_, output) in outputs {
106        for task in output {
107            println!("{}", task.stderr);
108        }
109    }
110}

Trait Implementations§

Source§

impl<T: Clone + Default + BuildParam<P>, P: Clone + BuildCmd> Clone for Executor<T, P>

Source§

fn clone(&self) -> Executor<T, P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Default + BuildParam<P>, P: Debug + BuildCmd> Debug for Executor<T, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, P> Freeze for Executor<T, P>

§

impl<T, P> RefUnwindSafe for Executor<T, P>

§

impl<T, P> Send for Executor<T, P>
where T: Send, P: Send,

§

impl<T, P> Sync for Executor<T, P>
where T: Sync, P: Sync,

§

impl<T, P> Unpin for Executor<T, P>
where T: Unpin, P: Unpin,

§

impl<T, P> UnwindSafe for Executor<T, P>
where T: UnwindSafe, P: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.