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
impl Package
Sourcepub fn new(
name: PackageName,
version: Version,
targets: Vec<Target>,
dependencies: Vec<Dependency>,
) -> Result<Self, ValidationError>
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 = truedeclarations - 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).
Sourcepub fn with_config(input: PackageConfigInput) -> Result<Self, ValidationError>
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.
Sourcepub fn with_profiles(
self,
profiles: BTreeMap<ProfileName, ProfileDefinition>,
) -> Self
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
impl Package
Sourcepub fn with_toolchain(self, toolchain: ToolchainSettings) -> Self
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.
Sourcepub fn with_build(self, build: ProfileSettings) -> Self
pub fn with_build(self, build: ProfileSettings) -> Self
Attach the manifest-declared [profile] /
[target.'cfg(...)'.profile] block. Per-package by design.
Sourcepub fn with_compiler_wrapper(
self,
settings: CompilerWrapperManifestSettings,
) -> Self
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.
Sourcepub fn with_patches(self, patches: PatchManifestSettings) -> Self
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.
Sourcepub fn resolved_dependencies(&self) -> impl Iterator<Item = &Dependency>
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.
Sourcepub fn dependencies_of_kind(
&self,
kind: DependencyKind,
) -> impl Iterator<Item = &Dependency>
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<'de> Deserialize<'de> for Package
impl<'de> Deserialize<'de> for Package
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Package
impl StructuralPartialEq for Package
Auto Trait Implementations§
impl Freeze for Package
impl RefUnwindSafe for Package
impl Send for Package
impl Sync for Package
impl Unpin for Package
impl UnsafeUnpin for Package
impl UnwindSafe for Package
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.