-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
MoirePrimitive and PolygonPrimitive enforce their invariants when they're being serialized.
Like this:
impl<W: Write> PartialGerberCode<W> for PolygonPrimitive {
fn serialize_partial(&self, writer: &mut W) -> GerberResult<()> {
// Vertice count invariants
if self.vertices < 3 {
return Err(GerberError::MissingDataError("There must be at least 3 vertices in a polygon".into()));
}
if self.vertices > 12 {
return Err(GerberError::RangeError("The maximum number of vertices in a polygon is 12".into()));
}
if self.diameter.is_negative() {
return Err(GerberError::RangeError("The diameter must not be negative".into()));
}Other types (like VectorLinePrimitive, etc.) should do this too 😃
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels