Skip to main content

ResourceEditor

Struct ResourceEditor 

Source
pub struct ResourceEditor<'m> { /* private fields */ }
Expand description

Transaction-staged writer for the bounded IFC4 resource slice.

Every create_* method validates the draft against the bundled schema and cross-attribute IFC rules before staging it, then commits through a single-entity ifc_model::Transaction.

Implementations§

Source§

impl ResourceEditor<'_>

Source

pub fn create_actor( &mut self, draft: ActorDraft<'_>, ) -> ResourceResult<EntityId>

Stage an IfcActor, or an IfcOccupant when a predefined type is given.

the_actor must resolve to an IfcActorSelect member. A record naming nobody identifies no party, so the reference is checked before staging.

§Errors

Refuses a malformed or duplicate GlobalId, a the_actor outside IfcActorSelect, a token outside IfcOccupantTypeEnum, a predefined type on a plain IfcActor, and USERDEFINED without ObjectType (WR31).

Source

pub fn create_asset( &mut self, draft: AssetDraft<'_>, ) -> ResourceResult<EntityId>

Stage an IfcAsset.

The three value slots are IfcCostValue references and the two party slots are IfcActorSelect; each is checked before staging so an asset cannot claim a value or an owner that the model does not hold.

§Errors

Refuses a malformed or duplicate GlobalId, a value reference that is not an IfcCostValue, a party outside IfcActorSelect, and a responsible person that is not an IfcPerson.

Source

pub fn create_inventory( &mut self, draft: InventoryDraft<'_>, responsible_persons: &[EntityId], ) -> ResourceResult<EntityId>

Stage an IfcInventory.

§Errors

Refuses a duplicate or malformed GlobalId, a jurisdiction outside IfcActorSelect, a value that is not an IfcCostValue, a responsible_persons entry that is not an IfcPerson, an empty person set (the schema bounds it SET [1:?]), and USERDEFINED without an object_type.

Source§

impl ResourceEditor<'_>

Source

pub fn create_actor_role( &mut self, draft: ActorRoleDraft<'_>, ) -> ResourceResult<EntityId>

Stage an IfcActorRole.

§Errors

Refuses a token outside IfcRoleEnum and USERDEFINED without a user_defined_role (WR1).

Source

pub fn create_postal_address( &mut self, draft: PostalAddressDraft<'_>, address_lines: &[&str], ) -> ResourceResult<EntityId>

Stage an IfcPostalAddress.

address_lines is LIST [1:?] when present.

§Errors

Refuses a purpose outside IfcAddressTypeEnum, USERDEFINED without a user_defined_purpose, and an address with no locating field at all (WR1).

Source

pub fn create_telecom_address( &mut self, draft: TelecomAddressDraft<'_>, lists: TelecomLists<'_>, ) -> ResourceResult<EntityId>

Stage an IfcTelecomAddress.

§Errors

Refuses a purpose outside IfcAddressTypeEnum, USERDEFINED without a user_defined_purpose, and an address carrying no contact route at all (MinimumDataProvided).

Source

pub fn create_organization_relationship( &mut self, name: Option<&str>, description: Option<&str>, relating: EntityId, related: &[EntityId], ) -> ResourceResult<EntityId>

Stage an IfcOrganizationRelationship.

§Errors

Refuses a reference that is not an IfcOrganization, an empty related set (SET [1:?]), and an organisation related to itself.

Source§

impl<'m> ResourceEditor<'m>

Source

pub fn for_model(model: &'m mut Model) -> ResourceResult<Self>

Opens an editor for model, verifying it declares a supported resource schema (IFC4 ADD2 TC1 or IFC4X3 ADD2).

Source

pub fn create_resource( &mut self, draft: ResourceDraft<'_>, ) -> ResourceResult<EntityId>

Commits a ResourceDraft as a new concrete IfcConstructionResource occurrence, failing if USERDEFINED is authored without ObjectType, or if Usage/BaseCosts/BaseQuantity reference entities of the wrong type.

Source

pub fn create_resource_type( &mut self, draft: ResourceDraft<'_>, ) -> ResourceResult<EntityId>

Commits a ResourceDraft as an IfcTypeResource subtype.

The type counterpart of ResourceEditor::create_resource: the shared definition several occurrences point at. The draft is reused because the two differ by one attribute, Usage, which belongs to the occurrence and is refused here rather than silently dropped.

PredefinedType is required on every resource type in the schema, unlike on the occurrence where it is optional.

§Errors

Refuses a duplicate or malformed GlobalId, a missing or unknown PredefinedType, a USERDEFINED type with no ObjectType to name it, a Usage reference, and any BaseCosts or BaseQuantity reference of the wrong type.

Source

pub fn create_time( &mut self, draft: ResourceTimeDraft<'_>, ) -> ResourceResult<EntityId>

Commits a ResourceTimeDraft as a new IfcResourceTime, failing if any ratio attribute is non-finite or not strictly positive.

Source

pub fn create_allocation( &mut self, draft: AllocationDraft<'_>, ) -> ResourceResult<EntityId>

Commits an AllocationDraft as a new IfcRelAssignsToResource, failing if RelatedObjects is empty, repeats a target, includes the resource itself, or references entities the RelatedObjectsType does not permit.

Source

pub fn create_nesting( &mut self, draft: NestingDraft<'_>, ) -> ResourceResult<EntityId>

Commits a NestingDraft as a new IfcRelNests, failing if RelatedObjects is empty, repeats a target, includes the parent itself, names a child that already has a resource parent, or would introduce a nesting cycle.

Source§

impl ResourceEditor<'_>

Source

pub fn create_applied_value( &mut self, draft: AppliedValueDraft<'_>, components: &[EntityId], ) -> ResourceResult<EntityId>

Create an IfcAppliedValue, optionally composed from components.

An applied value is a cost-like quantity: a value, the unit basis it is quoted per, and the dates it applies between. It may instead be composed, combining components with an arithmetic operator.

The schema states no WHERE rule tying the two together, but a composition without an operator does not say how to combine its parts, and an operator without components has nothing to combine; both are refused rather than written for a reader to guess at.

Components is LIST [1:?] OF IfcAppliedValue, so an empty list is left absent rather than written as (), which would satisfy the type and break the bound.

§Errors

Refuses an arithmetic_operator the target schema does not declare, an operator/components pair where only one side is present, a component that is not an IfcAppliedValue, and an applied_value outside IfcAppliedValueSelect.

Auto Trait Implementations§

§

impl<'m> !UnwindSafe for ResourceEditor<'m>

§

impl<'m> Freeze for ResourceEditor<'m>

§

impl<'m> RefUnwindSafe for ResourceEditor<'m>

§

impl<'m> Send for ResourceEditor<'m>

§

impl<'m> Sync for ResourceEditor<'m>

§

impl<'m> Unpin for ResourceEditor<'m>

§

impl<'m> UnsafeUnpin for ResourceEditor<'m>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.