pub enum Dependency {
And(Vec<DependencyType>),
Or(Vec<DependencyType>),
}Expand description
Sbatch dependency representation
Represents the different types of dependencies that can be used in a Slurm job script. See https://slurm.schedmd.com/sbatch.html for more information.
And(Vec<DependencyType>): The job can start after all of the specified dependencies have been met.Or(Vec<DependencyType>): The job can start after any of the specified dependencies have been met.
§Examples
use sbatch_rs::{Dependency, DependencyType};
// Create a new `And` dependency
let dependency = Dependency::new_and()
.push(DependencyType::After("123".to_string())).unwrap() // Add an `After` dependency
.push_after_time_delay("456", "10").unwrap() // Add an `AfterTimeDelay` dependency
.build().unwrap(); // Build the dependency string
// Check that the dependency string is correct
assert_eq!(dependency, "after:123,after:456+10");Variants§
And(Vec<DependencyType>)
Or(Vec<DependencyType>)
Implementations§
Source§impl Dependency
impl Dependency
Sourcepub fn push(
&mut self,
dependency: DependencyType,
) -> Result<&mut Self, DependencyError>
pub fn push( &mut self, dependency: DependencyType, ) -> Result<&mut Self, DependencyError>
Add a dependency to the Dependency enum.
§Arguments
dependency- ADependencyTypevalue to add to theDependencyenum.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::{Dependency, DependencyType};
// Create a new `And` dependency
let mut dependency = Dependency::new_and();
// Add an `After` dependency using the enum variant
dependency.push(DependencyType::After("123".to_string())).unwrap();
// Build the dependency string
let dependency_str = dependency.build().unwrap();
assert_eq!(dependency_str, "after:123");Sourcepub fn push_after(
&mut self,
job_id: impl ToString,
) -> Result<&mut Self, DependencyError>
pub fn push_after( &mut self, job_id: impl ToString, ) -> Result<&mut Self, DependencyError>
Add an After dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after("123").unwrap()
.build().unwrap();
assert_eq!(dependency, "after:123");
Sourcepub fn push_after_time_delay(
&mut self,
job_id: impl ToString,
time_delay: impl ToString,
) -> Result<&mut Self, DependencyError>
pub fn push_after_time_delay( &mut self, job_id: impl ToString, time_delay: impl ToString, ) -> Result<&mut Self, DependencyError>
Add an AfterTimeDelay dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.time_delay- The time delay to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after_time_delay("123", "10").unwrap()
.build().unwrap();
assert_eq!(dependency, "after:123+10");Sourcepub fn push_after_any(
&mut self,
job_id: impl ToString,
) -> Result<&mut Self, DependencyError>
pub fn push_after_any( &mut self, job_id: impl ToString, ) -> Result<&mut Self, DependencyError>
Add an AfterAny dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after_any("123").unwrap()
.build().unwrap();
assert_eq!(dependency, "afterany:123");Sourcepub fn push_after_burst_buffer(
&mut self,
job_id: impl ToString,
) -> Result<&mut Self, DependencyError>
pub fn push_after_burst_buffer( &mut self, job_id: impl ToString, ) -> Result<&mut Self, DependencyError>
Add an AfterBurstBuffer dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after_burst_buffer("123").unwrap()
.build().unwrap();
assert_eq!(dependency, "afterburstbuffer:123");
Sourcepub fn push_after_corr(
&mut self,
job_id: impl ToString,
) -> Result<&mut Self, DependencyError>
pub fn push_after_corr( &mut self, job_id: impl ToString, ) -> Result<&mut Self, DependencyError>
Add an AfterCorr dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after_corr("123").unwrap()
.build().unwrap();
assert_eq!(dependency, "aftercorr:123");Sourcepub fn push_after_not_ok(
&mut self,
job_id: impl ToString,
) -> Result<&mut Self, DependencyError>
pub fn push_after_not_ok( &mut self, job_id: impl ToString, ) -> Result<&mut Self, DependencyError>
Add an AfterNotOk dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after_not_ok("123").unwrap()
.build().unwrap();
assert_eq!(dependency, "afternotok:123");Sourcepub fn push_after_ok(
&mut self,
job_id: &str,
) -> Result<&mut Self, DependencyError>
pub fn push_after_ok( &mut self, job_id: &str, ) -> Result<&mut Self, DependencyError>
Add an AfterOk dependency to the Dependency enum.
§Arguments
job_id- The job ID to add as a dependency.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
This function returns a DependencyError if the dependency is invalid.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_after_ok("123").unwrap()
.build().unwrap();
assert_eq!(dependency, "afterok:123");Sourcepub fn push_singleton(&mut self) -> Result<&mut Self, DependencyError>
pub fn push_singleton(&mut self) -> Result<&mut Self, DependencyError>
Add a Singleton dependency to the Dependency enum.
§Returns
This function returns a mutable reference to the Dependency enum.
§Errors
Note that the Singleton dependency type does not require any arguments.
Currently, this function does not return any errors but may be updated in the future.
§Examples
use sbatch_rs::Dependency;
let dependency = Dependency::new_and()
.push_singleton().unwrap()
.build().unwrap();
assert_eq!(dependency, "singleton");Sourcepub fn build(&self) -> Result<String, DependencyError>
pub fn build(&self) -> Result<String, DependencyError>
Build the dependency string.
§Returns
This function returns a String containing the dependency string.
§Errors
This function returns a DependencyError if the dependency is invalid.
The NoDependencies error is returned if no dependencies were provided.
The DependencyTypeError error is returned if a dependency is invalid.
§Examples
use sbatch_rs::{Dependency, DependencyType};
// Create a new `And` dependency
let mut dependency = Dependency::new_and();
// Add an `After` dependency using the enum variant
dependency.push(DependencyType::After("123".to_string())).unwrap();
// Add a `AfterTimeDelay` dependency using the helper function
dependency.push_after_time_delay("456", "10").unwrap();
// Build the dependency string
let dependency_str = dependency.build().unwrap();
assert_eq!(dependency_str, "after:123,after:456+10");Trait Implementations§
Source§impl Clone for Dependency
impl Clone for Dependency
Source§fn clone(&self) -> Dependency
fn clone(&self) -> Dependency
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more