Trait StudentFilePolicy

Source
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§

Source

fn new_with_project_config(project_config: TmcProjectYml) -> Self
where Self: Sized,

This constructor should store the project config in the implementing struct.

Source

fn get_project_config(&self) -> &TmcProjectYml

The policy should contain a TmcProjectYml parsed from the project this policy was created for.

Source

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§

Source

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.

Source

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.

Source

fn is_updating_forced(&self, path: &Path) -> Result<bool, TmcError>

Used to check for files which should always be overwritten.

The file_path should be relative, starting from the project root.

Implementations on Foreign Types§

Source§

impl StudentFilePolicy for CSharpStudentFilePolicy

Source§

impl StudentFilePolicy for AntStudentFilePolicy

Source§

impl StudentFilePolicy for MavenStudentFilePolicy

Source§

impl StudentFilePolicy for MakeStudentFilePolicy

Source§

impl StudentFilePolicy for NoTestsStudentFilePolicy

Source§

impl StudentFilePolicy for Python3StudentFilePolicy

Source§

impl StudentFilePolicy for RStudentFilePolicy

Implementors§