MatchError#
The error returned by slots of the plen-assign crate. It reports either an invalid item in the pool or the requirements, or a project state that doesn't allow building slots. It converts into the core Error , so ? works in functions that return plen_core::Error.
Declaration#
Copy # [ derive ( Clone, Debug, PartialEq ) ]
pub enum MatchError {
Invalid { path: String , message: String } ,
Project( ProjectError) ,
}
impl std:: error:: Error for MatchError { }
impl std:: fmt:: Display for MatchError { }
impl From < MatchError> for plen_core ::Error { }
Variants#
Variant
When it occurs
Invalid { path, message }
An item of the pool or a requirement is invalid. path names the item, for example requirements[2].assignments[0]; message says what's wrong with it.
Project(ProjectError)
The project has no accepted baseline: it's unsolved, or it has unsolved edits after apply . The wrapped value is ProjectError::NoBaseline .
Invalid paths#
Path
When it occurs
pool.workers[i].resource
Unknown resource, or the same resource listed as two workers
pool.workers[i].skills[j].id
The same skill listed twice on one worker
pool.workers[i].skills[j].value
Not finite
requirements[i].id
Duplicate requirement id, or one of its slot ids is an active assignment on another task
requirements[i].task
Unknown or unscheduled task
requirements[i].count
0
requirements[i].units
Not finite, or <= 0
requirements[i].matches[j].value
Not finite
requirements[i].assignments
More entries than count, or an assignment with one of this requirement's slot ids is left out of the list
requirements[i].assignments[k]
Unknown or inactive assignment, an assignment on another task, or an assignment bound twice
Display#
Variant
Output
Invalid
"{path}: {message}"
Project
The ProjectError text, for example no-baseline
Conversion to Error#
MatchError
plen_core::Error
Invalid { path, message }
Error::Input : an InputError of kind Validation, with path: Some(path) and the same message
Project(e)
Error::Project(e)
Example#
Copy use plen_assign:: { slots, MatchError, Pool} ;
use plen_core:: { Project, ProjectError} ;
fn main ( ) {
let project = Project:: default( ) ;
match slots ( & project, & Pool:: default( ) , & [ ] ) {
Ok ( slots) => println! ( " {} slots" , slots. len ( ) ) ,
Err ( MatchError:: Project( ProjectError:: NoBaseline) ) => println! ( " solve the project first" ) ,
Err ( MatchError:: Project( e) ) => println! ( " project error: {e} " ) ,
Err ( MatchError:: Invalid { path, message } ) => println! ( " {path} : {message} " ) ,
}
}
slots - the function that returns this error
Error - the core error a MatchError converts into with ?
ProjectError - the type wrapped by the Project variant
Error handling - shows how to match MatchError from the skill layer
Skills and Requirements - lists the skill-layer errors in the full workflow