# Struct cassowary::Solver
[−]
[src]

pub struct Solver { /* fields omitted */ }

A constraint solver using the Cassowary algorithm. For proper usage please see the top level crate documentation.

## Methods

`impl Solver`

[src]

`impl Solver`

`pub fn new() -> Solver`

[src]

`pub fn new() -> Solver`

Construct a new solver.

`pub fn add_constraints<'a, I: IntoIterator<Item = &'a Constraint>>(`

&mut self,

constraints: I

) -> Result<(), AddConstraintError>

[src]

`pub fn add_constraints<'a, I: IntoIterator<Item = &'a Constraint>>(`

&mut self,

constraints: I

) -> Result<(), AddConstraintError>

`pub fn add_constraint(`

&mut self,

constraint: Constraint

) -> Result<(), AddConstraintError>

[src]

`pub fn add_constraint(`

&mut self,

constraint: Constraint

) -> Result<(), AddConstraintError>

Add a constraint to the solver.

`pub fn remove_constraint(`

&mut self,

constraint: &Constraint

) -> Result<(), RemoveConstraintError>

[src]

`pub fn remove_constraint(`

&mut self,

constraint: &Constraint

) -> Result<(), RemoveConstraintError>

Remove a constraint from the solver.

`pub fn has_constraint(&self, constraint: &Constraint) -> bool`

[src]

`pub fn has_constraint(&self, constraint: &Constraint) -> bool`

Test whether a constraint has been added to the solver.

`pub fn add_edit_variable(`

&mut self,

v: Variable,

strength: f64

) -> Result<(), AddEditVariableError>

[src]

`pub fn add_edit_variable(`

&mut self,

v: Variable,

strength: f64

) -> Result<(), AddEditVariableError>

Add an edit variable to the solver.

This method should be called before the `suggest_value`

method is
used to supply a suggested value for the given edit variable.

`pub fn remove_edit_variable(`

&mut self,

v: Variable

) -> Result<(), RemoveEditVariableError>

[src]

`pub fn remove_edit_variable(`

&mut self,

v: Variable

) -> Result<(), RemoveEditVariableError>

Remove an edit variable from the solver.

`pub fn has_edit_variable(&self, v: &Variable) -> bool`

[src]

`pub fn has_edit_variable(&self, v: &Variable) -> bool`

Test whether an edit variable has been added to the solver.

`pub fn suggest_value(`

&mut self,

variable: Variable,

value: f64

) -> Result<(), SuggestValueError>

[src]

`pub fn suggest_value(`

&mut self,

variable: Variable,

value: f64

) -> Result<(), SuggestValueError>

Suggest a value for the given edit variable.

This method should be used after an edit variable has been added to the solver in order to suggest the value for that variable.

`pub fn fetch_changes(&mut self) -> &[(Variable, f64)]`

[src]

`pub fn fetch_changes(&mut self) -> &[(Variable, f64)]`

Fetches all changes to the values of variables since the last call to this function.

The list of changes returned is not in a specific order. Each change comprises the variable changed and the new value of that variable.

`pub fn reset(&mut self)`

[src]

`pub fn reset(&mut self)`

Reset the solver to the empty starting condition.

This method resets the internal solver state to the empty starting condition, as if no constraints or edit variables have been added. This can be faster than deleting the solver and creating a new one when the entire system must change, since it can avoid unnecessary heap (de)allocations.

`pub fn get_value(&self, v: Variable) -> f64`

[src]

`pub fn get_value(&self, v: Variable) -> f64`

Get the stored value for a variable.

Normally values should be retrieved and updated using `fetch_changes`

, but
this method can be used for debugging or testing.