Skip to main content

BatteryPackSpec

Struct BatteryPackSpec 

Source
pub struct BatteryPackSpec {
    pub name: String,
    pub version: String,
    pub description: String,
    pub repository: Option<String>,
    pub keywords: Vec<String>,
    pub crates: BTreeMap<String, CrateSpec>,
    pub features: BTreeMap<String, BTreeSet<String>>,
    pub hidden: BTreeSet<String>,
    pub templates: BTreeMap<String, TemplateSpec>,
}
Expand description

Parsed battery pack specification.

This is the core data model extracted from a battery pack’s Cargo.toml. All curated crates, features, hidden deps, and templates are represented here.

Fields§

§name: String

Crate name (e.g., cli-battery-pack).

§version: String

Version string.

§description: String

Package description.

§repository: Option<String>

Repository URL.

§keywords: Vec<String>

Package keywords.

§crates: BTreeMap<String, CrateSpec>

All curated crates, keyed by crate name.

§features: BTreeMap<String, BTreeSet<String>>

Named features from [features], mapping feature name to crate names.

§hidden: BTreeSet<String>

Hidden dependency patterns (may include globs).

§templates: BTreeMap<String, TemplateSpec>

Templates registered in metadata.

Implementations§

Source§

impl BatteryPackSpec

Source

pub fn validate(&self) -> Result<(), Error>

Validate that this looks like a valid battery pack.

Source

pub fn validate_spec(&self) -> ValidationReport

Comprehensive spec validation — collects all issues rather than failing on the first one. Checks data-only rules from the spec.

Source

pub fn resolve_crates( &self, active_features: &[&str], ) -> BTreeMap<String, CrateSpec>

Resolve which crates should be installed for the given active features.

With no features specified (empty slice), returns the default set: crates from the default feature, or all non-optional crates if no default feature exists.

Features are additive — each named feature adds its crates on top.

Source

pub fn resolve_all(&self) -> BTreeMap<String, CrateSpec>

Resolve all crates regardless of features or optional status.

Source

pub fn resolve_all_visible(&self) -> BTreeMap<String, CrateSpec>

Resolve all visible (non-hidden) crates regardless of features or optional status.

Source

pub fn resolve_for_features( &self, active_features: &BTreeSet<String>, ) -> BTreeMap<String, CrateSpec>

Resolve crates for a set of active features, handling the “all” sentinel.

If active_features contains "all", returns all visible crates. Otherwise delegates to resolve_crates.

Source

pub fn is_hidden(&self, crate_name: &str) -> bool

Check whether a crate name matches the hidden patterns.

Source

pub fn visible_crates(&self) -> BTreeMap<&str, &CrateSpec>

Return all non-hidden crates.

Source

pub fn all_crates_with_grouping( &self, ) -> Vec<(String, String, &CrateSpec, bool)>

Return all visible (non-hidden) crates grouped by feature, with a flag indicating whether each crate is in the default set.

Returns Vec<(group_name, crate_name, &CrateSpec, is_default)>. Crates not in any feature are grouped under "default".

Source

pub fn has_meaningful_choices(&self) -> bool

Returns true if this battery pack has meaningful choices for the user (more than 3 crates or has named features beyond default).

Trait Implementations§

Source§

impl Clone for BatteryPackSpec

Source§

fn clone(&self) -> BatteryPackSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BatteryPackSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.