pub trait StudentFilePolicy {
// Required methods
fn new_with_project_config(project_config: TmcProjectYml) -> Self
where Self: Sized;
fn get_project_config(&self) -> &TmcProjectYml;
fn is_non_extra_student_file(&self, file_path: &Path) -> bool;
// Provided methods
fn new(project_dir: &Path) -> Result<Self, TmcError>
where Self: Sized { ... }
fn is_student_file(&self, file_path: &Path) -> bool { ... }
fn is_updating_forced(&self, path: &Path) -> Result<bool, TmcError> { ... }
}Expand description
Specifies which files are student files. A single StudentFilePolicy is only valid for a single project as it uses a config file to determine its output.
Student files are any files that are expected to be modified and/or created by the student. That is, any files that should not be overwritten when when updating an already downloaded exercise and any files that should be submitted to the server.
Required Methods§
Sourcefn new_with_project_config(project_config: TmcProjectYml) -> Selfwhere
Self: Sized,
fn new_with_project_config(project_config: TmcProjectYml) -> Selfwhere
Self: Sized,
This constructor should store the project config in the implementing struct.
Sourcefn get_project_config(&self) -> &TmcProjectYml
fn get_project_config(&self) -> &TmcProjectYml
The policy should contain a TmcProjectYml parsed from the project this policy was created for.
Sourcefn is_non_extra_student_file(&self, file_path: &Path) -> bool
fn is_non_extra_student_file(&self, file_path: &Path) -> bool
Used by is_student_file. Defines a language plugin policy’s rules for determining whether a file is a student file or not.
Provided Methods§
Sourcefn new(project_dir: &Path) -> Result<Self, TmcError>where
Self: Sized,
fn new(project_dir: &Path) -> Result<Self, TmcError>where
Self: Sized,
Parses a project config and calls the helper constructor. Implementing types should only be constructed using this function.
Sourcefn is_student_file(&self, file_path: &Path) -> bool
fn is_student_file(&self, file_path: &Path) -> bool
Determines whether a file is a student source file.
A file should be considered a student source file if it resides in a location the student is expected to create his or her own source files in the general case. Any special cases are specified as ExtraStudentFiles in a separate configuration.
For example in a Java project that uses Apache Ant, should return true for any files in the src directory.
The file_path should be relative to the project root path.