pub trait Shape: Send + Sync {
// Required method
fn path(&self) -> Path2D;
// Provided methods
fn validate(&self) -> Result<(), ValidationError> { ... }
fn bounding_box(&self) -> Rect { ... }
fn as_rect(&self) -> Option<Rect> { ... }
fn fill(self, paint: impl Into<Paint>) -> Styled<Self>
where Self: Sized { ... }
fn stroke(self, width: f64, paint: impl Into<Paint>) -> Styled<Self>
where Self: Sized { ... }
}Expand description
Logical geometry independent of paint and node placement.
Custom geometry must keep path and bounds consistent and deterministic. Direct path conversion requires valid geometry; invalid raw rectangles panic there, while recording their filled nodes reports validation errors instead.
Required Methods§
Provided Methods§
Sourcefn validate(&self) -> Result<(), ValidationError>
fn validate(&self) -> Result<(), ValidationError>
Reports retained authoring errors before measuring or drawing.
Sourcefn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
Geometric bounds; defaults to the path’s cached curve bounds.
Sourcefn as_rect(&self) -> Option<Rect>
fn as_rect(&self) -> Option<Rect>
Exact rectangle equivalent, when available, for a rule-independent fast path.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".