Crate manifest_feature_gen

Source
Expand description

manifest-feature-gen helps generating features of cargo manifest

§Usage

use manifest_feature_gen::{Manifest, ToFeatureName};

enum Features {
    Feature1,
    Feature2,
}

impl ToFeatureName for Features {
    fn to_feature_name(&self) -> String {
        match self {
            Features::Feature1 => "feature1".to_string(),
            Features::Feature2 => "feature2".to_string(),
        }
    }
}

fn main() -> Result<(), manifest_feature_gen::Error> {
    let mut manifest = Manifest::new("Cargo.toml")?;
    let optional_features = manifest.add_features([
        Features::Feature1,
        Features::Feature2,
    ].into_iter(), |_, _| {}).unwrap();
    manifest.write()?;
    Ok(())
}

Structs§

BuildScriptExportDescriptor
Build script export descriptor. It describes how to export features to build script.
DependencyHelper
This helper provides some safe way to specify dependency of generated feature
Manifest
Cargo manifest representation for editing features.
ManifestWithBuildScript
Cargo manifest representation for generating features on out of build script
ManifestWithFeatureCollector
Cargo manifest representation for generating feature on build script.

Enums§

DependencyError
Possible dependency error from DependencyHelper
Error
Possible errors while using manifest-feature-gen

Traits§

ToFeatureName
Provide feature name for write to cargo manifest. Recommend write in snake_case or kebab-case