Skip to main content

Transform

Enum Transform 

Source
#[non_exhaustive]
pub enum Transform { SplitUnit { unit: UnitId, numerator: u64, denominator: NonZeroU64, dependents: SplitDependents, overhead: Millis, }, RemoveEdge { from: UnitId, to: UnitId, }, RemoveUnits { units: Vec<UnitId>, }, }
Expand description

A hypothetical edit to a build graph.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SplitUnit

Divide one unit into two, as splitting a crate in a refactor would.

The first part receives numerator / denominator of the unit’s work, rounded to nearest, and the second receives the remainder, so the two parts sum to exactly the original weight. overhead is then added to each part, because two crates re-parse shared imports and each pays a fixed per-crate cost.

A part’s metadata_at is scaled by that part’s share of the denominator and then clamped so that it never exceeds the part’s own total. The clamp is reachable through rounding alone: a unit of 999ms that emits metadata at 999ms, divided at one half, gives parts of 500ms and 499ms while both metadata times round to 500ms, and the second is clamped to 499ms. overhead is added to the total but not to metadata_at, so the metadata boundary of a part is the earliest the split could plausibly reach.

Both parts inherit every incoming edge with its original kind, along with kind and requires_full_closure. Where the outgoing edges go is decided by dependents: SplitDependents::Pessimistic gives every dependent an edge from both parts, and SplitDependents::Optimistic gives each dependent one edge, from the part that finishes first.

A build script cannot be split: one invocation of one program is not divisible, and numerator may not exceed denominator.

Fields

§unit: UnitId

The unit to divide.

§numerator: u64

The numerator of the fraction of the work the first part receives.

§denominator: NonZeroU64

The denominator of that fraction.

§dependents: SplitDependents

Which part each dependent is assumed to need.

§overhead: Millis

The fixed cost each part pays for being a separate crate.

§

RemoveEdge

Remove one dependency edge, as deleting a use of one crate from another would.

Only the edge goes; both units stay, even if one of them is left with nothing depending on it. Removing a unit is Transform::RemoveUnits.

Fields

§from: UnitId

The producer the edge leaves.

§to: UnitId

The consumer the edge arrives at.

§

RemoveUnits

Remove units, as dropping a dependency or turning off a feature would.

Removing a unit also removes everything that existed only to serve it. Precisely: let a root be a unit that had no dependents in the original graph, which is what the build was asked to produce. After the named units are removed, every surviving unit that can no longer reach a surviving root by following dependents is removed as well. Reachability is reflexive, so a surviving root reaches itself and always survives.

Naming a unit twice is not an error, and removing every unit gives a valid empty graph.

Fields

§units: Vec<UnitId>

The units to remove.

Trait Implementations§

Source§

impl Clone for Transform

Source§

fn clone(&self) -> Self

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 Transform

Source§

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

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

impl Eq for Transform

Source§

impl PartialEq for Transform

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Transform

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.