Expand description
cargo-culture-kit provides machinery for checking project-level rules about Rust best practices.
The primary function entry points are check_culture and
check_culture_default.
The core trait is Rule, which represents a single project-level property
that has a clear description and can be checked.
§Examples
check_culture_default is the easiest way to get started,
as it provides a thin wrapper around the core check_culture
function in combination with the Rules provided by the
default_rules() function.
use cargo_culture_kit::{check_culture_default, IsSuccess, OutcomeStats};
use std::path::PathBuf;
let cargo_manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("Cargo.toml");
let verbose = false;
let outcomes = check_culture_default(
cargo_manifest, verbose, &mut std::io::stdout()
)
.expect("Unexpected trouble checking culture rules:");
let stats = OutcomeStats::from(outcomes);
assert!(stats.is_success());
assert_eq!(stats.fail_count, 0);
assert_eq!(stats.undetermined_count, 0);If you want to use a specific Rule or group of Rules,
the check_culture function is the right place to look.
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);Re-exports§
pub use checklist::filter_to_requested_rules_by_description;pub use checklist::filter_to_requested_rules_from_checklist_file;pub use checklist::find_extant_culture_file;pub use checklist::FilterError;pub use checklist::DEFAULT_CULTURE_CHECKLIST_FILE_NAME;pub use exit_code::ExitCode;pub use rules::default_rules;pub use rules::BuildsCleanlyWithoutWarningsOrErrors;pub use rules::CargoMetadataReadable;pub use rules::HasContinuousIntegrationFile;pub use rules::HasContributingFile;pub use rules::HasLicenseFile;pub use rules::HasReadmeFile;pub use rules::HasRustfmtFile;pub use rules::PassesMultipleTests;pub use rules::Rule;pub use rules::RuleContext;pub use rules::RuleOutcome;pub use rules::UsesPropertyBasedTestLibrary;
Modules§
- checklist
- Helper functions related to the interpretation and filtering of
Ruledescription checklists. - exit_
code - Program exit code hinting through the
ExitCodetrait - rules
- Provides the
Ruletrait and several implementations, available through thedefault_rules()function.
Structs§
- Cargo
Metadata - Starting point for metadata returned by
cargo metadata - Outcome
Stats - Summary of result statistics generated from aggregating
RuleOutcomes results for multiple Rule evaluations
Enums§
- Check
Error - Top-level error variants for what can go wrong with checking culture rules.
Traits§
- IsSuccess
- Trait for summarizing whether the outcome of culture checking was a total success for any of the various levels of outcome aggregation
Functions§
- check_
culture - Given a set of
Rules, evaluate the rules and produce a summary report of the rule outcomes. - check_
culture_ default - Execute a
check_culturerun using the set of rules available fromdefault_rules.
Type Aliases§
- Outcomes
ByDescription - Map between the
descriptionofRules and the outcome of their execution