ifc_cost/lib.rs
1//! `ifc-cost` — cost semantics as a **view** over the model.
2//!
3//! # This crate owns no data
4//!
5//! It borrows a `&Model` and interprets entities that happen to be cost
6//! entities. That is the whole design: the model stores structure, this crate
7//! supplies meaning, and the two are separable.
8//!
9//! The consequences are the point:
10//!
11//! - **Optional.** An application that never touches cost compiles none of
12//! this. It is a cargo feature of the `ifc` facade crate.
13//! - **Non-destructive.** Because the model holds the same entities with or
14//! without this crate, a file with cost data round-trips identically in
15//! either build. Verified in `ifc/tests/costing_roundtrip.rs`, which runs
16//! with no domain crate compiled at all.
17//! - **Replaceable.** A different interpretation of the same entities is
18//! another crate, not a fork of the model.
19//!
20//! # Modules
21//!
22//! | Module | Role |
23//! | --- | --- |
24//! | [`view`] | [`CostView`]: the entry point, borrows a `&Model` |
25//! | [`item`] | `IfcCostItem`: the individual line |
26//! | [`schedule`] | `IfcCostSchedule`: the containing document |
27//! | [`value`] | `IfcCostValue` and applied monetary values |
28//! | [`quantity`] | Quantities a cost is computed against |
29//! | [`relation`] | Nesting and control assignment |
30//! | [`mutation`] | Transaction-staged bounded IFC4 authoring; release-bound quantities |
31//! | [`currency`] | Monetary unit agreement |
32//! | [`rollup`] | Summing a cost tree |
33//! | [`error`] | Why a cost lookup failed |
34//!
35//! ```
36//! use ifc_cost::CostView;
37//! use ifc_model::{Entity, EntityId, Model, Value};
38//!
39//! let mut model = Model::new();
40//! model.insert(
41//! EntityId(1),
42//! Entity::new("IFCCOSTITEM", vec![
43//! Value::Text("guid".into()), Value::Null, Value::Text("Excavation".into()),
44//! ]),
45//! );
46//!
47//! let view = CostView::new(&model);
48//! assert_eq!(view.items().next().unwrap().name(), Some("Excavation"));
49//! ```
50
51pub mod currency;
52pub mod error;
53pub mod item;
54pub mod mutation;
55pub mod quantity;
56pub mod relation;
57pub mod rollup;
58pub mod schedule;
59pub mod value;
60pub mod view;
61
62pub use currency::{monetary_units, project_currency, CurrencyError};
63pub use error::CostError;
64/// The IFC release a release-bound authoring error names (re-exported from
65/// `ifc-schema`).
66pub use ifc_schema::SchemaVersion;
67pub use item::CostItem;
68pub use mutation::{
69 assign_schedule_items, assign_schedule_items_with_owner_history, create_cost_item,
70 create_cost_item_with_owner_history, create_cost_schedule,
71 create_cost_schedule_with_owner_history, create_cost_value, create_currency_relationship,
72 create_monetary_unit, nest_cost_items, nest_cost_items_with_owner_history, CostAuthoringError,
73 CostAuthoringResult, CostItemDraft, CostItemType, CostScheduleDraft, CostScheduleType,
74 CostValueDraft, CostValueKind, NestingDraft, ScheduleAssignmentDraft,
75};
76pub use quantity::CostQuantity;
77pub use relation::{
78 children_of, controlled_by, controls_of, descendants_of, nesting_anomalies, parent_of,
79 parents_of, CostAnomaly, CostRelationError, MAX_NESTING_DEPTH,
80};
81pub use rollup::{consistency, direct_total, grand_total, rolled_up_total, roots, Consistency};
82pub use schedule::CostSchedule;
83pub use value::{ArithmeticOperator, CostValue, UnitBasis};
84pub use view::CostView;