pub struct LayerStack { /* private fields */ }Expand description
A main layer and everything it imports, each once, in federation order: every layer after its imports, the main layer last.
Implementations§
Source§impl LayerStack
impl LayerStack
Sourcepub fn layers(&self) -> &[Layer]
pub fn layers(&self) -> &[Layer]
All layers in federation order, weakest first: every layer after the layers it imports, the main layer last. See the module docs.
Sourcepub fn into_layers(self) -> Vec<Layer>
pub fn into_layers(self) -> Vec<Layer>
The layers in federation order, as layers.
Sourcepub fn federate(&self) -> IfcxFile
pub fn federate(&self) -> IfcxFile
Merges the stack into one file, as upstream’s Federate does before
composing: the main layer’s header, no imports, schemas from every
layer, and the data of every layer in federation order, so that a
layer’s opinions override those of the layers it imports.
A schema id defined by several layers keeps the position where it first
appears and takes the value of the last layer. Data nodes are not
merged; several nodes may share a path, and flatten
applies them in order so that later opinions win.
Sourcepub fn into_federated(self) -> IfcxFile
pub fn into_federated(self) -> IfcxFile
federate for a stack that is not needed
afterwards: the layers’ schemas and data move into the result instead
of being copied. Pass its data to flatten_owned to keep
composition free of copies too.
Sourcepub fn validate(&self) -> Result<(), ValidationReport>
pub fn validate(&self) -> Result<(), ValidationReport>
Checks the attributes of the whole stack: the schemas of every layer,
merged as federate does, against the attributes of
every layer’s data, merged per path as flatten
does. This is IfcxFile::validate of the federated file, without
copying it.
So an attribute whose schema lives only in an imported file validates, and only the value that wins for a path is checked.
use openbim_ifcx::layers::{LayerStackBuilder, MemoryResolver};
let header = r#""header": {"id": "x", "ifcxVersion": "ifcx_alpha", "dataVersion": "1.0.0",
"author": "someone", "timestamp": "2026-10-03"}"#;
let mut resolver = MemoryResolver::new();
resolver.insert("main", format!(r#"{{{header}, "imports": [{{"uri": "schemas"}}],
"schemas": {{}}, "data": [{{"path": "w", "attributes": {{"demo::height": 2.5}}}}]}}"#));
resolver.insert("schemas", format!(r#"{{{header}, "imports": [], "data": [],
"schemas": {{"demo::height": {{"value": {{"dataType": "Real"}}}}}}}}"#));
let stack = LayerStackBuilder::new(resolver).build("main")?;
// The main layer alone does not know `demo::height`; its stack does.
assert!(stack.main().file().validate().is_err());
assert!(stack.validate().is_ok());Trait Implementations§
Source§impl Clone for LayerStack
impl Clone for LayerStack
Source§fn clone(&self) -> LayerStack
fn clone(&self) -> LayerStack
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more