SupplyManager

Struct SupplyManager 

Source
pub struct SupplyManager { /* private fields */ }
Expand description

Manager that holds and provides supplies.

The SupplyManager is the central registry for all supplies used by the solver. It creates supplies on-demand when first requested and caches them for reuse.

§Thread Safety

The manager uses Arc for shared ownership, allowing supplies to be accessed from multiple threads during parallel solving.

Implementations§

Source§

impl SupplyManager

Source

pub fn new() -> Self

Creates a new empty supply manager.

Source

pub fn demand<D: SupplyDemand>(&mut self, demand: &D) -> Arc<D::Output>

Gets or creates a supply for the given demand.

If the supply already exists, returns a clone of the Arc. Otherwise, creates a new supply using the demand’s create_supply method.

Source

pub fn register<S: Supply>(&mut self, key: DemandKey, supply: Arc<S>)

Registers a pre-created supply.

This is useful when supplies are created externally and need to be registered with the manager.

Source

pub fn get<S: Supply>(&self, key: &DemandKey) -> Option<Arc<S>>

Gets an existing supply without creating one.

Returns None if the supply has not been created yet.

Source

pub fn remove(&mut self, key: &DemandKey) -> bool

Removes a supply from the manager.

Source

pub fn clear(&mut self)

Clears all supplies from the manager.

Source

pub fn len(&self) -> usize

Returns the number of registered supplies.

Source

pub fn is_empty(&self) -> bool

Returns true if no supplies are registered.

Trait Implementations§

Source§

impl Debug for SupplyManager

Source§

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

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

impl Default for SupplyManager

Source§

fn default() -> SupplyManager

Returns the “default value” for a type. Read more

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> 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, 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.