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<'_>
impl ResourceEditor<'_>
Sourcepub fn create_actor(
&mut self,
draft: ActorDraft<'_>,
) -> ResourceResult<EntityId>
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).
Sourcepub fn create_asset(
&mut self,
draft: AssetDraft<'_>,
) -> ResourceResult<EntityId>
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.
Sourcepub fn create_inventory(
&mut self,
draft: InventoryDraft<'_>,
responsible_persons: &[EntityId],
) -> ResourceResult<EntityId>
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<'_>
impl ResourceEditor<'_>
Sourcepub fn create_actor_role(
&mut self,
draft: ActorRoleDraft<'_>,
) -> ResourceResult<EntityId>
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).
Sourcepub fn create_postal_address(
&mut self,
draft: PostalAddressDraft<'_>,
address_lines: &[&str],
) -> ResourceResult<EntityId>
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).
Sourcepub fn create_telecom_address(
&mut self,
draft: TelecomAddressDraft<'_>,
lists: TelecomLists<'_>,
) -> ResourceResult<EntityId>
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).
Sourcepub fn create_organization_relationship(
&mut self,
name: Option<&str>,
description: Option<&str>,
relating: EntityId,
related: &[EntityId],
) -> ResourceResult<EntityId>
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>
impl<'m> ResourceEditor<'m>
Sourcepub fn for_model(model: &'m mut Model) -> ResourceResult<Self>
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).
Sourcepub fn create_resource(
&mut self,
draft: ResourceDraft<'_>,
) -> ResourceResult<EntityId>
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.
Sourcepub fn create_resource_type(
&mut self,
draft: ResourceDraft<'_>,
) -> ResourceResult<EntityId>
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.
Sourcepub fn create_time(
&mut self,
draft: ResourceTimeDraft<'_>,
) -> ResourceResult<EntityId>
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.
Sourcepub fn create_allocation(
&mut self,
draft: AllocationDraft<'_>,
) -> ResourceResult<EntityId>
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.
Sourcepub fn create_nesting(
&mut self,
draft: NestingDraft<'_>,
) -> ResourceResult<EntityId>
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<'_>
impl ResourceEditor<'_>
Sourcepub fn create_applied_value(
&mut self,
draft: AppliedValueDraft<'_>,
components: &[EntityId],
) -> ResourceResult<EntityId>
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.