pub struct ViewConstraints { /* private fields */ }Expand description
Owns one parsed sheet and cached identities without per-request parsing.
All fit, centering, clamping, and zoom-limit arithmetic lives in the sheet. Errors leave the model available for subsequent updates, but do not promise rollback of writes already propagated.
§Examples
let model = adam_web_ui::graph::ViewConstraints::new();
assert!(model.is_ok());Implementations§
Source§impl ViewConstraints
impl ViewConstraints
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Parses and propagates the embedded sheet using the configured library host.
§Errors
Returns a formatted diagnostic for invalid sheet syntax, missing cells, evaluation failure, or incomplete/non-finite initial outputs.
- Complexity: O(s² + n + p) time and O(s + n + p) space for installed
signatures
s, source lengthn, and the sheet’s propagation workp.
§Examples
let mut model = adam_web_ui::graph::ViewConstraints::new()?;Sourcepub fn update(&mut self, input: ViewInput) -> Result<ViewOutput>
pub fn update(&mut self, input: ViewInput) -> Result<ViewOutput>
Validates inputs, writes geometry and requested sources, and propagates.
Refresh preserves the original pan/zoom aspiration; Fit copies only the sheet’s derived fit into those sources and propagates a second time.
§Errors
Returns an error for non-finite/unordered/unrepresentable bounds, nonpositive/non-finite viewport or proposed zoom, non-finite proposed pan, sheet evaluation failure, or incomplete/non-finite/nonpositive outputs. A failed update never returns a fallback view.
- Complexity: O(p) time and space in sheet propagation work; no parsing.
§Examples
let mut model = ViewConstraints::new()?;
let output = model.update(ViewInput {
bounds: Rect::default(),
viewport: Size2D::new(400.0, 300.0),
action: ViewAction::Fit,
})?;
assert_eq!(output.view.k, 300.0);