Skip to main content

Spec

Trait Spec 

Source
pub trait Spec: Serialize + DeserializeOwned {
    type Args: Serialize + DeserializeOwned;
    type Quirk: Serialize + DeserializeOwned;

    // Required methods
    fn schema_version(&self) -> u32;
    fn root_key(&self) -> &str;
    fn member_keys(&self) -> Vec<&str>;
    fn args_for(&self, key: &str) -> Option<&Self::Args>;
    fn quirks_for(&self, key: &str) -> &[Self::Quirk];
}
Expand description

The typed shape an adapter’s build spec exposes to substrate + tooling consumers. Every adapter’s BuildSpec struct implements this; the trait method surface is universal.

Why the associated types: each ecosystem carries its own Args shape (BuildRustCrateArgs for Cargo, NpmInstallArgs for npm, …) and its own Quirk enum. The trait doesn’t constrain the shapes — substrate dispatches on the serialized JSON. What the trait DOES constrain is the universal accessor surface (schema_version / root_key / member_keys / args_for / quirks_for) so substrate’s Nix dispatch is written once.

Required Associated Types§

Source

type Args: Serialize + DeserializeOwned

Per-package buildRustCrate-equivalent args.

Source

type Quirk: Serialize + DeserializeOwned

Per-package quirks variant set (typed by the adapter).

Required Methods§

Source

fn schema_version(&self) -> u32

Spec schema version. Substrate’s lockfile-builder asserts this >= a known floor; cse-lint flags stale specs.

Source

fn root_key(&self) -> &str

The workspace’s primary buildable package key.

Source

fn member_keys(&self) -> Vec<&str>

Every package the workspace tracks (root + members).

Source

fn args_for(&self, key: &str) -> Option<&Self::Args>

Pre-shaped build args for one package, or None if the package isn’t in the spec.

Source

fn quirks_for(&self, key: &str) -> &[Self::Quirk]

Quirks registered for one package — empty when no quirks apply, never None.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§