[−][src]Trait stdbench::source::PisaSource
Defines how to acquire PISA programs for later execution.
Required methods
fn executor(&self, config: &Config) -> Result<Box<dyn PisaExecutor>, Error>
Initially, a source only holds information. At this stage, it runs any processes required to acquire PISA executables, and returns an executor object.
Example
In the following example, the code in the last line will clone
the repository and build the source code (unless config
suppresses
this stage).
let source = GitSource::new( "https://github.com/pisa-engine/pisa.git", "master" ); let config = Config::new(PathBuf::from("/workdir"), Box::new(source.clone())); let executor = source.executor(&config);
Typically, however, you would directly run executor()
method of config
,
which will internally run the function of source
:
let executor = config.executor();
Methods
impl dyn PisaSource
pub fn is<__T: PisaSource>(&self) -> bool
Returns true if the trait object wraps an object of type __T
.
pub fn downcast<__T: PisaSource>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn't.
pub fn downcast_ref<__T: PisaSource>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn't.
pub fn downcast_mut<__T: PisaSource>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn't.
impl dyn PisaSource
[src]
pub fn parse(yaml: &Yaml) -> Result<Box<dyn PisaSource>, Error>
[src]
Constructs PisaSource
object from a YAML object.
extern crate yaml_rust; let yaml = yaml_rust::YamlLoader::load_from_str(" type: git url: http://git.url branch: master").unwrap(); let source = PisaSource::parse(&yaml[0]); assert_eq!( source.unwrap().downcast_ref::<GitSource>(), Some(&GitSource::new("http://git.url", "master")) );