Skip to main content

LayerStack

Struct LayerStack 

Source
pub struct LayerStack { /* private fields */ }
Expand description

A main layer and everything it imports, each once, in upstream order.

Implementations§

Source§

impl LayerStack

Source

pub fn main(&self) -> &Layer

The layer the stack was built from.

Source

pub fn layers(&self) -> &[Layer]

All layers, main layer first. See the module docs for the order.

Source

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

Layer keys in stack order.

Source

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

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 stack order.

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) -> Self

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 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: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.