[][src]Struct lab_grader::batch::Batch

pub struct Batch {
    pub name: String,
    pub desc: Option<String>,
    pub criteria: Criteria,
    pub total: isize,
}

A bundle of metadata with a set of criteria.

The main purpose of a Batch is to deserialize criteria from a yaml file. This struct provides a from_yaml method that takes yaml data and turns it into a batch.

Specification for the yaml data

Fields

name: Stringdesc: Option<String>criteria: Criteriatotal: isize

Implementations

impl Batch[src]

pub fn from_yaml(yaml: &str) -> Self[src]

Builds a Batch from yaml data

This method calls parse() from the FromStr. parse() returns a Result, and this method just prints the result in a clean way and exits with exit. It's just one less thing to unwrap.

exiting from within a library function is usually bad practice, but this will only exit if the yaml passed in has an error. The yaml you'll write to form a Batch is written during development, and is embedded in the executable. This means that if you're code compiles, it can be distributed and this will never exit.

If you want to deal with the result yourself, call parse instead of this.

Example

use lab_grader::*;

let yaml_data = yaml!("../test_data/test_batch.yml").expect("Couldn't open that file");
let batch = Batch::from_yaml(yaml_data);

// Now you've got a batch
assert!(batch.name.len() > 1);

pub fn attach(&mut self, stub: &str, func: Box<dyn Fn(&TestData) -> bool>)[src]

Gets a criterion by stub

pub fn print_short(&self)[src]

An alternative to printing through println!("{}", batch).

This prints a shorted report where each criterion is on it's own line, and only the criterion name and status is printed. The batch description is also hidden.

Trait Implementations

impl Display for Batch[src]

impl FromStr for Batch[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl !RefUnwindSafe for Batch

impl !Send for Batch

impl !Sync for Batch

impl Unpin for Batch

impl !UnwindSafe for Batch

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoCollection<T> for T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any