ifc_alignment/authoring/
mod.rs1mod layout;
17mod linear;
18mod referent;
19mod segment;
20
21pub use layout::{alignment, alignment_segment, cant_layout, horizontal_layout, vertical_layout};
22pub use linear::{linear_element, linear_positioning_element};
23pub use referent::{
24 axis2_placement_linear, cartesian_point, linear_placement, point_by_distance, referent,
25 stationing,
26};
27pub use segment::{
28 cant_segment, horizontal_segment, vertical_segment, CantSegmentDraft, HorizontalSegmentDraft,
29 VerticalSegmentDraft,
30};
31
32use ifc_model::Value;
33
34use crate::error::AlignmentError;
35
36pub(crate) fn invalid(
38 type_name: &'static str,
39 attribute: &'static str,
40 detail: impl Into<String>,
41) -> AlignmentError {
42 AlignmentError::InvalidAuthoredValue {
43 type_name,
44 attribute,
45 detail: detail.into(),
46 }
47}
48
49pub(crate) fn finite(
52 type_name: &'static str,
53 attribute: &'static str,
54 value: f64,
55) -> Result<(), AlignmentError> {
56 if value.is_finite() {
57 Ok(())
58 } else {
59 Err(invalid(
60 type_name,
61 attribute,
62 format!("{value} is not finite"),
63 ))
64 }
65}
66
67pub(crate) fn guid(type_name: &'static str, value: &str) -> Result<Value, AlignmentError> {
70 if value.chars().count() != 22 {
71 return Err(invalid(
72 type_name,
73 "GlobalId",
74 format!("expected 22 characters, got {}", value.chars().count()),
75 ));
76 }
77 Ok(Value::Text(value.into()))
78}