Struct LayerStack

Source
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

Source

pub fn main(&self) -> &Layer

The main layer: the one build started from, which is the last layer of the stack. For build_all it is the last layer too, the strongest of the named ones.

Source

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.

Source

pub fn keys(&self) -> impl Iterator<Item = &str>

Layer keys in federation order, as layers.

Source

pub fn into_layers(self) -> Vec<Layer>

The layers in federation order, as layers.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> LayerStack

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LayerStack

Source§

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

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

impl PartialEq for LayerStack

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 StructuralPartialEq for LayerStack

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.