Function cargo_culture_kit::check_culture[][src]

pub fn check_culture<P: AsRef<Path>, W: Write>(
    cargo_manifest_file_path: P,
    verbose: bool,
    print_output: &mut W,
    rules: &[&Rule]
) -> Result<OutcomesByDescription, CheckError>

Given a set of Rules, evaluate the rules and produce a summary report of the rule outcomes.

Primary entry point for this library.

cargo_manifest_file_path should point to a project's extant Cargo.toml file. Either a crate-level or a workspace-level toml file should work.

verbose controls whether or not to produce additional human-readable reporting.

print_output is the Write instance where Rule evaluation summaries are printed, as well as the location where verbose content may be dumped. &mut std::io::stdout() is a common instance used by non-test applications.

rules is the complete set of Rule instances which will be evaluated for the project specified by cargo_manifest_file_path.

Examples

use cargo_culture_kit::{check_culture, IsSuccess, OutcomeStats,
HasLicenseFile}; use std::path::PathBuf;

let rule = HasLicenseFile::default();
let cargo_manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .join("Cargo.toml");

let verbose = false;

let outcomes = check_culture(cargo_manifest, verbose, &mut
std::io::stdout(),     &[&rule])
    .expect("Unexpected trouble checking culture rules: ");

let stats = OutcomeStats::from(outcomes);
assert!(stats.is_success());
assert_eq!(stats.success_count, 1);
assert_eq!(stats.fail_count, 0);
assert_eq!(stats.undetermined_count, 0);

Errors

Returns an error if the program cannot write to the supplied print_output instance.