Crate cargo_culture_kit[][src]

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::Rule;
pub use rules::RuleContext;
pub use rules::RuleOutcome;

Modules

checklist

Helper functions related to the interpretation and filtering of Rule description checklists.

exit_code

Program exit code hinting through the ExitCode trait

rules

Provides the Rule trait and several implementations, available through the default_rules() function.

Structs

BuildsCleanlyWithoutWarningsOrErrors

Rule that asserts a good Rust project: "Should cargo clean and cargo build without any warnings or errors."

CargoMetadata

Starting point for metadata returned by cargo metadata

CargoMetadataReadable

Rule that asserts a good Rust project: "Should have a well-formed Cargo.toml file readable by cargo metadata"

HasContinuousIntegrationFile

Rule that asserts a good Rust project: "Should have a file suggesting the use of a continuous integration system."

HasContributingFile

Rule that asserts a good Rust project: "Should have a CONTRIBUTING file in the project directory."

HasLicenseFile

Rule that asserts a good Rust project: "Should have a LICENSE file in the project directory."

HasReadmeFile

Rule that asserts a good Rust project: "Should have a README.md file in the project directory."

HasRustfmtFile

Rule that asserts a good Rust project: "Should have a rustfmt.toml file in the project directory."

OutcomeStats

Summary of result statistics generated from aggregating RuleOutcomes results for multiple Rule evaluations

PassesMultipleTests

Rule that asserts a good Rust project: "Should have multiple tests which pass."

UsesPropertyBasedTestLibrary

Rule that asserts a good Rust project: "Should be making an effort to use property based tests."

Enums

CheckError

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_culture run using the set of rules available from default_rules.

Type Definitions

OutcomesByDescription

Map between the description of Rules and the outcome of their execution