Skip to main content

RuleSpec

Enum RuleSpec 

Source
pub enum RuleSpec {
Show 25 variants Fix { param: ParamRef, value: f64, }, Equal { a: ParamRef, b: ParamRef, }, AllEqual { params: Vec<ParamRef>, }, Linear { terms: Vec<Term>, op: Cmp, rhs: f64, }, Ratio { a: ParamRef, b: ParamRef, k: f64, }, EqualSpacing { params: Vec<ParamRef>, }, Coincident { a: AnchorRef, b: AnchorRef, }, Horizontal { a: AnchorRef, b: AnchorRef, }, Vertical { a: AnchorRef, b: AnchorRef, }, FixPoint { a: AnchorRef, at: Point, }, Distance { a: AnchorRef, b: AnchorRef, value: f64, }, PointLineDistance { point: AnchorRef, line: LineRef, value: f64, }, PointOnLine { point: AnchorRef, line: LineRef, }, PointOnCircle { point: AnchorRef, circle: EntityId, }, Length { line: LineRef, value: f64, }, EqualLength { a: LineRef, b: LineRef, }, Parallel { a: LineRef, b: LineRef, }, Perpendicular { a: LineRef, b: LineRef, }, Angle { a: LineRef, b: LineRef, value: f64, }, Concentric { a: EntityId, b: EntityId, }, Radius { circle: EntityId, value: f64, }, EqualRadius { a: EntityId, b: EntityId, }, TangentLineCircle { line: LineRef, circle: EntityId, side: f64, }, TangentCircles { a: EntityId, b: EntityId, internal: bool, sign: f64, }, Expression { entity: EntityId, lhs: String, op: Cmp, rhs: String, },
}
Expand description

Constraint kinds.

Variants§

§

Fix

param = value.

Fields

§param: ParamRef

Parameter.

§value: f64

Value (canonical units).

§

Equal

a = b.

Fields

§a: ParamRef

First parameter.

§b: ParamRef

Second parameter.

§

AllEqual

All parameters equal.

Fields

§params: Vec<ParamRef>

Parameters.

§

Linear

Σ coef·param (op) rhs — sums, differences, minimums, maximums.

Fields

§terms: Vec<Term>

Terms.

§op: Cmp

Operator.

§rhs: f64

Right-hand side.

§

Ratio

a = k · b.

Fields

§a: ParamRef

Numerator parameter.

§b: ParamRef

Denominator parameter.

§k: f64

Constant ratio.

§

EqualSpacing

Consecutive differences equal (equally spaced values).

Fields

§params: Vec<ParamRef>

Parameters in order.

§

Coincident

Coincident anchors.

Fields

§a: AnchorRef

First anchor.

§b: AnchorRef

Second anchor.

§

Horizontal

Two anchors share Y.

Fields

§a: AnchorRef

First anchor.

§b: AnchorRef

Second anchor.

§

Vertical

Two anchors share X.

Fields

§a: AnchorRef

First anchor.

§b: AnchorRef

Second anchor.

§

FixPoint

Anchor fixed at a point.

Fields

§a: AnchorRef

Anchor.

§at: Point

Location (world coordinates).

§

Distance

Distance between anchors.

Fields

§a: AnchorRef

First anchor.

§b: AnchorRef

Second anchor.

§value: f64

Distance (mm, ≥ 0).

§

PointLineDistance

Signed distance from an anchor to a line (positive = left of the line).

Fields

§point: AnchorRef

Point.

§line: LineRef

Line.

§value: f64

Signed distance (mm).

§

PointOnLine

Anchor on the infinite line.

Fields

§point: AnchorRef

Point.

§line: LineRef

Line.

§

PointOnCircle

Anchor on a circle/arc entity.

Fields

§point: AnchorRef

Point.

§circle: EntityId

Circle or arc entity.

§

Length

Line length.

Fields

§line: LineRef

Line.

§value: f64

Length (mm).

§

EqualLength

Equal line lengths.

Fields

§a: LineRef

First line.

§b: LineRef

Second line.

§

Parallel

Parallel lines.

Fields

§a: LineRef

First line.

§b: LineRef

Second line.

§

Perpendicular

Perpendicular lines.

Fields

§a: LineRef

First line.

§b: LineRef

Second line.

§

Angle

Signed angle from a to b.

Fields

§a: LineRef

First line.

§b: LineRef

Second line.

§value: f64

Angle (radians).

§

Concentric

Circles/arcs share their center.

Fields

§a: EntityId

First circle/arc.

§b: EntityId

Second circle/arc.

§

Radius

Radius value.

Fields

§circle: EntityId

Circle/arc.

§value: f64

Radius (mm).

§

EqualRadius

Equal radii.

Fields

§a: EntityId

First circle/arc.

§b: EntityId

Second circle/arc.

§

TangentLineCircle

Line tangent to circle; side (±1) is the side of the line the circle is on.

Fields

§line: LineRef

Line.

§circle: EntityId

Circle/arc.

§side: f64

+1 left of the line, −1 right.

§

TangentCircles

Circle–circle tangency.

Fields

§a: EntityId

First circle/arc.

§b: EntityId

Second circle/arc.

§internal: bool

Internal tangency (one inside the other).

§sign: f64

For internal tangency: +1 when a is the outer circle.

§

Expression

Expression rule in the Dotloom expression language, evaluated in Rust: lhs (op) rhs, e.g. "self.offset + self.width" <= "host.length".

Fields

§entity: EntityId

Entity whose namespace (self, references) the expressions use.

§lhs: String

Left expression.

§op: Cmp

Operator.

§rhs: String

Right expression.

Implementations§

Source§

impl RuleSpec

Source

pub fn entities(&self) -> Vec<EntityId>

Entities referenced by the rule.

Source

pub fn anchors(&self) -> Vec<&AnchorRef>

Anchor references used by the rule.

Source

pub fn params(&self) -> Vec<&ParamRef>

Parameter references used by the rule.

Source

pub fn remap(&mut self, map: &BTreeMap<EntityId, EntityId>) -> bool

Remap entity references (used by copy/paste). Returns false if any referenced entity has no mapping.

Source

pub fn kind_name(&self) -> &'static str

Stable kind name.

Source

pub fn values_valid(&self) -> bool

Numeric fields are finite and within their domain.

Trait Implementations§

Source§

impl Clone for RuleSpec

Source§

fn clone(&self) -> RuleSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RuleSpec

Source§

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

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

impl<'de> Deserialize<'de> for RuleSpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RuleSpec

Source§

fn eq(&self, other: &RuleSpec) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for RuleSpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RuleSpec

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.