Skip to main content

SolverState

Struct SolverState 

Source
pub struct SolverState<E: BodyEvaluator> { /* private fields */ }
Expand description

Live state of the solver.

Implementations§

Source§

impl<E: BodyEvaluator> SolverState<E>

Source

pub fn new(graph: ModuleGraph, evaluator: E) -> Self

Construct a fresh solver for graph. Builds the reverse- dependency index up-front so per-iteration scheduling is O(1) per dirty path.

Source

pub fn env(&self) -> &EnvSnapshot

Borrow the current env snapshot.

Source

pub fn graph(&self) -> &ModuleGraph

Borrow the compiled graph back out.

Source

pub fn setter_count(&self) -> usize

Total setter count across all modules.

Source

pub fn schedule_for_dirty( &self, dirty_paths: &[ConfigPath], ) -> BTreeSet<GlobalSetterId>

Find every CONSUMER setter that needs to fire because at least one of dirty_paths matches a prefix of its slice.

“Matches a prefix” means: if a setter’s slice is [["services", "atticd"]] and dirty_paths contains ["services", "atticd", "enable"], the setter is scheduled — a slice over a subtree fires on any descendant change.

Writers are deliberately not included here. A writer’s own re-firing happens only when its OWN slice changes (covered by the readers lookup that finds it as a consumer of its upstream’s outputs). Multi-writer conflict resolution happens at the evaluator layer via ConfigSetter::priority — firing each writer once per topo pass is enough.

Source

pub fn topological_order(&self) -> Result<Vec<GlobalSetterId>, SolverError>

Topological order of all setters by writes→reads dependency. Kahn’s algorithm.

§Errors

SolverError::Cycle if the writes→reads graph has a cycle (which is a module-author bug — cppnix would also fail here).

Source

pub fn fire(&mut self, gid: GlobalSetterId) -> Result<ConfigPath, SolverError>

Fire one setter, write its result into the env, mark it fired. Returns the setter’s own assigns_path so callers can register it as newly-dirty.

§Errors

SolverError::BodyEval when the body evaluator rejects.

Source

pub fn run( &mut self, initial_dirty: &[ConfigPath], ) -> Result<Vec<GlobalSetterId>, SolverError>

Run the solver to quiescence starting from initial_dirty. Returns the firing order in temporal sequence. Caller can inspect Self::env afterward for the final config attrset.

On a cold rebuild (no env, no prior dirty), pass an empty initial_dirty and the solver runs every setter in topological order. On a warm rebuild where only services.atticd.enable changed, pass [vec!["services", "atticd", "enable"]] and only the setters depending on that slice fire.

§Errors

Cycles or body-eval failures surface as SolverError.

Auto Trait Implementations§

§

impl<E> Freeze for SolverState<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for SolverState<E>
where E: RefUnwindSafe,

§

impl<E> Send for SolverState<E>
where E: Send,

§

impl<E> Sync for SolverState<E>
where E: Sync,

§

impl<E> Unpin for SolverState<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for SolverState<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for SolverState<E>
where E: UnwindSafe,

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> 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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

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