Skip to main content

Package

Struct Package 

Source
pub struct Package {
    pub name: PackageName,
    pub version: Version,
    pub targets: Vec<Target>,
    pub dependencies: Vec<Dependency>,
    pub system_dependencies: Vec<SystemDependency>,
    pub features: Features,
    pub profiles: BTreeMap<ProfileName, ProfileDefinition>,
    pub toolchain: ToolchainSettings,
    pub build: ProfileSettings,
    pub compiler_wrapper: CompilerWrapperManifestSettings,
    pub patches: PatchManifestSettings,
}
Expand description

Top-level validated package.

Fields§

§name: PackageName§version: Version§targets: Vec<Target>§dependencies: Vec<Dependency>

Cabin package dependencies declared under [dependencies] or [dev-dependencies]. Each entry carries its DependencyKind; iteration order is sorted by (kind, name) so callers see deterministic output.

§system_dependencies: Vec<SystemDependency>

system = true declarations. Empty if not declared. System dependencies never enter the resolver, the lockfile, or the artifact cache; they are declaration-only and round-trip through metadata.

§features: Features

[features] declarations. Empty if the manifest has no [features] table.

§profiles: BTreeMap<ProfileName, ProfileDefinition>

[profile.<name>] declarations from the manifest, keyed by profile name. Built-in profiles do not need to appear here; entries that match a built-in name override those defaults. Empty for manifests with no profile tables, so older manifests stay byte-identical through round-tripping.

§toolchain: ToolchainSettings

[toolchain] plus any [target.'cfg(...)'.toolchain] overrides declared on this manifest. Only the workspace root manifest’s settings are honored; member manifests that declare a [toolchain] table are rejected by the workspace loader.

§build: ProfileSettings

[profile] plus any [target.'cfg(...)'.profile] declarations for this package. Per-package by design — each package may add its own defines / include dirs / extra args.

The raw compiler / linker flag arrays (cflags / cxxflags / ldflags) are honored only for local packages — the workspace root, its members, and path dependencies. They are dropped for registry dependencies during flag resolution (see resolve_build_flags), because they are unvalidated and could otherwise smuggle build-time code-execution options such as -fplugin=. defines and include_dirs are validated and kept for every package.

§compiler_wrapper: CompilerWrapperManifestSettings

[profile.cache] plus any [target.'cfg(...)'.profile.cache] declarations from the workspace root manifest. Member manifests cannot declare cache settings — the workspace loader rejects them — so reading off the root is sufficient. Round-trips through metadata so packaged manifests preserve a publisher’s declared wrapper preferences.

§patches: PatchManifestSettings

[patch] declarations on the workspace-root manifest. Member manifests cannot declare patches — the workspace loader rejects them — and cabin package refuses to archive a manifest with a non-empty [patch] table. Patches are local development policy, not package metadata.

Implementations§

Source§

impl Package

Source

pub fn new( name: PackageName, version: Version, targets: Vec<Target>, dependencies: Vec<Dependency>, ) -> Result<Self, ValidationError>

Build a validated Package.

Validation:

  • target names are unique
  • dependency names are unique within each kind (the same name may legitimately appear under multiple kinds)
  • system dependency names are unique within the collected system = true declarations
  • feature declarations are well-formed

Target-dep references (same-package, cross-package, or qualified package:target) are resolved by cabin-build against the full package graph, not here.

§Errors

Returns a ValidationError when validation fails: see Package::with_config, which performs the checks (ValidationError::DuplicateTargetName, ValidationError::DuplicateDependency, and feature-table errors).

Source

pub fn with_config(input: PackageConfigInput) -> Result<Self, ValidationError>

Build a validated Package with [features] declarations attached. cabin-manifest calls this after parsing the [features] table.

§Errors

Returns ValidationError::DuplicateTargetName for repeated target names, ValidationError::DuplicateDependency for a duplicate dependency within a kind, ValidationError::DuplicateSystemDependency for a duplicate system dependency, and propagates any ValidationError from validating the [features] table.

Source

pub fn with_profiles( self, profiles: BTreeMap<ProfileName, ProfileDefinition>, ) -> Self

Attach manifest-declared [profile.*] definitions to this package. Returns the same package so callers can chain it after Package::with_config without exploding the constructor signature for every new optional table.

Source§

impl Package

Source

pub fn with_toolchain(self, toolchain: ToolchainSettings) -> Self

Attach the manifest-declared [toolchain] / [target.'cfg(...)'.toolchain] block. Workspace loaders reject these declarations on member / path-dep manifests so only the entry-point manifest’s value reaches downstream crates.

Source

pub fn with_build(self, build: ProfileSettings) -> Self

Attach the manifest-declared [profile] / [target.'cfg(...)'.profile] block. Per-package by design.

Source

pub fn with_compiler_wrapper( self, settings: CompilerWrapperManifestSettings, ) -> Self

Attach the manifest-declared [profile.cache] / [target.'cfg(...)'.profile.cache] blocks. Workspace loaders reject these declarations on member / path-dep manifests so only the entry-point manifest’s value reaches downstream crates.

Source

pub fn with_patches(self, patches: PatchManifestSettings) -> Self

Attach the manifest-declared [patch] block. Workspace loaders reject these declarations on member / path-dep manifests so only the entry-point manifest’s value reaches downstream crates.

Source

pub fn resolved_dependencies(&self) -> impl Iterator<Item = &Dependency>

Iterator over the package dependencies that participate in the resolver / fetch / build pipeline by default — i.e. every Cabin package dependency except Dev.

Source

pub fn dependencies_of_kind( &self, kind: DependencyKind, ) -> impl Iterator<Item = &Dependency>

Iterator over dependencies of a specific kind. Order is the same as dependencies (sorted by (kind, name)).

Trait Implementations§

Source§

impl Clone for Package

Source§

fn clone(&self) -> Package

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Package

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Package

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Package

Source§

fn eq(&self, other: &Package) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Package

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Package

Source§

impl StructuralPartialEq for Package

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,