Skip to main content

ifc_classification/authoring/
builders.rs

1//! Constructors and builder setters for the drafts of the parent module,
2//! kept apart so the writer stays under the 800-line limit.
3
4#[allow(clippy::wildcard_imports)]
5use super::*;
6
7impl<'a> ClassificationDraft<'a> {
8    /// Starts a draft from its required fields; every other field is unset.
9    #[must_use]
10    pub fn new(name: &'a str) -> Self {
11        Self {
12            source: None,
13            edition: None,
14            edition_date: None,
15            name,
16            description: None,
17            location: None,
18            reference_tokens: None,
19        }
20    }
21
22    /// Sets `source`: `Source` publishing organization, when stated. Required
23    /// by IFC2X3.
24    #[must_use]
25    pub fn source(mut self, value: &'a str) -> Self {
26        self.source = Some(value);
27        self
28    }
29
30    /// Sets `edition`: `Edition` identifier of the classification, when stated.
31    /// Required by IFC2X3.
32    #[must_use]
33    pub fn edition(mut self, value: &'a str) -> Self {
34        self.edition = Some(value);
35        self
36    }
37
38    /// Sets `edition_date`: `EditionDate` (IFC date string), when stated.
39    /// IFC2X3 types it as an `IfcCalendarDate` record, so text is refused
40    /// there.
41    #[must_use]
42    pub fn edition_date(mut self, value: &'a str) -> Self {
43        self.edition_date = Some(value);
44        self
45    }
46
47    /// Sets `description`: `Description` of the classification, when stated.
48    /// IFC4 onwards.
49    #[must_use]
50    pub fn description(mut self, value: &'a str) -> Self {
51        self.description = Some(value);
52        self
53    }
54
55    /// Sets `location`: `Location` (URI) of the classification, when stated:
56    /// written to `Specification` in IFC4X3. IFC4 onwards.
57    #[must_use]
58    pub fn location(mut self, value: &'a str) -> Self {
59        self.location = Some(value);
60        self
61    }
62
63    /// Sets `reference_tokens`: `ReferenceTokens` delimiter set; must be non-
64    /// empty when given. IFC4 onwards.
65    #[must_use]
66    pub fn reference_tokens(mut self, value: &'a [&'a str]) -> Self {
67        self.reference_tokens = Some(value);
68        self
69    }
70}
71
72impl<'a> ClassificationReferenceDraft<'a> {
73    /// Starts an empty draft; every field is unset.
74    #[must_use]
75    pub fn new() -> Self {
76        Self {
77            location: None,
78            identification: None,
79            name: None,
80            referenced_source: None,
81            description: None,
82            sort: None,
83        }
84    }
85
86    /// Sets `location`: `Location` (URI) of the reference; at least one of
87    /// location/identification/name must be given.
88    #[must_use]
89    pub fn location(mut self, value: &'a str) -> Self {
90        self.location = Some(value);
91        self
92    }
93
94    /// Sets `identification`: `Identification` code within the classification,
95    /// when stated (`ItemReference` in IFC2X3).
96    #[must_use]
97    pub fn identification(mut self, value: &'a str) -> Self {
98        self.identification = Some(value);
99        self
100    }
101
102    /// Sets `name`: `Name` of the referenced item, when stated.
103    #[must_use]
104    pub fn name(mut self, value: &'a str) -> Self {
105        self.name = Some(value);
106        self
107    }
108
109    /// Sets `referenced_source`: `ReferencedSource`: the parent
110    /// `IfcClassification` or `IfcClassificationReference` (only an
111    /// `IfcClassification` in IFC2X3), when stated.
112    #[must_use]
113    pub fn referenced_source(mut self, value: EntityId) -> Self {
114        self.referenced_source = Some(value);
115        self
116    }
117
118    /// Sets `description`: `Description` of the reference, when stated. IFC4
119    /// onwards.
120    #[must_use]
121    pub fn description(mut self, value: &'a str) -> Self {
122        self.description = Some(value);
123        self
124    }
125
126    /// Sets `sort`: `Sort` order token, when stated. IFC4 onwards.
127    #[must_use]
128    pub fn sort(mut self, value: &'a str) -> Self {
129        self.sort = Some(value);
130        self
131    }
132}
133
134impl<'a> DocumentDraft<'a> {
135    /// Starts a draft from its required fields; every other field is unset.
136    #[must_use]
137    pub fn new(identification: &'a str, name: &'a str) -> Self {
138        Self {
139            identification,
140            name,
141            description: None,
142            location: None,
143            purpose: None,
144            intended_use: None,
145            scope: None,
146            revision: None,
147            document_owner: None,
148            editors: None,
149            creation_time: None,
150            last_revision_time: None,
151            electronic_format: None,
152            valid_from: None,
153            valid_until: None,
154            confidentiality: None,
155            status: None,
156        }
157    }
158
159    /// Sets `description`: `Description` of the document, when stated.
160    #[must_use]
161    pub fn description(mut self, value: &'a str) -> Self {
162        self.description = Some(value);
163        self
164    }
165
166    /// Sets `location`: `Location` (URI) of the document, when stated. IFC4
167    /// onwards.
168    #[must_use]
169    pub fn location(mut self, value: &'a str) -> Self {
170        self.location = Some(value);
171        self
172    }
173
174    /// Sets `purpose`: `Purpose` of the document, when stated.
175    #[must_use]
176    pub fn purpose(mut self, value: &'a str) -> Self {
177        self.purpose = Some(value);
178        self
179    }
180
181    /// Sets `intended_use`: `IntendedUse` of the document, when stated.
182    #[must_use]
183    pub fn intended_use(mut self, value: &'a str) -> Self {
184        self.intended_use = Some(value);
185        self
186    }
187
188    /// Sets `scope`: `Scope` of the document, when stated.
189    #[must_use]
190    pub fn scope(mut self, value: &'a str) -> Self {
191        self.scope = Some(value);
192        self
193    }
194
195    /// Sets `revision`: `Revision` identifier, when stated.
196    #[must_use]
197    pub fn revision(mut self, value: &'a str) -> Self {
198        self.revision = Some(value);
199        self
200    }
201
202    /// Sets `document_owner`: `DocumentOwner`: an `IfcActorSelect`, when
203    /// stated.
204    #[must_use]
205    pub fn document_owner(mut self, value: EntityId) -> Self {
206        self.document_owner = Some(value);
207        self
208    }
209
210    /// Sets `editors`: `Editors`: non-empty unique set of `IfcActorSelect` ids,
211    /// when stated.
212    #[must_use]
213    pub fn editors(mut self, value: &'a [EntityId]) -> Self {
214        self.editors = Some(value);
215        self
216    }
217
218    /// Sets `creation_time`: `CreationTime` (IFC date-time string), when
219    /// stated. IFC2X3 types it as an `IfcDateAndTime` record, so text is
220    /// refused there.
221    #[must_use]
222    pub fn creation_time(mut self, value: &'a str) -> Self {
223        self.creation_time = Some(value);
224        self
225    }
226
227    /// Sets `last_revision_time`: `LastRevisionTime` (IFC date-time string),
228    /// when stated. A record in IFC2X3, as `creation_time`.
229    #[must_use]
230    pub fn last_revision_time(mut self, value: &'a str) -> Self {
231        self.last_revision_time = Some(value);
232        self
233    }
234
235    /// Sets `electronic_format`: `ElectronicFormat`, when stated. IFC2X3 types
236    /// it as an `IfcDocumentElectronicFormat` record, so text is refused there.
237    #[must_use]
238    pub fn electronic_format(mut self, value: &'a str) -> Self {
239        self.electronic_format = Some(value);
240        self
241    }
242
243    /// Sets `valid_from`: `ValidFrom` (IFC date string), when stated. An
244    /// `IfcCalendarDate` record in IFC2X3.
245    #[must_use]
246    pub fn valid_from(mut self, value: &'a str) -> Self {
247        self.valid_from = Some(value);
248        self
249    }
250
251    /// Sets `valid_until`: `ValidUntil` (IFC date string), when stated. An
252    /// `IfcCalendarDate` record in IFC2X3.
253    #[must_use]
254    pub fn valid_until(mut self, value: &'a str) -> Self {
255        self.valid_until = Some(value);
256        self
257    }
258
259    /// Sets `confidentiality`: `Confidentiality` enumerator; must be one of the
260    /// release's `IfcDocumentConfidentialityEnum` values.
261    #[must_use]
262    pub fn confidentiality(mut self, value: &'a str) -> Self {
263        self.confidentiality = Some(value);
264        self
265    }
266
267    /// Sets `status`: `Status` enumerator; must be one of the release's
268    /// `IfcDocumentStatusEnum` values.
269    #[must_use]
270    pub fn status(mut self, value: &'a str) -> Self {
271        self.status = Some(value);
272        self
273    }
274}
275
276impl<'a> DocumentReferenceDraft<'a> {
277    /// Starts an empty draft; every field is unset.
278    #[must_use]
279    pub fn new() -> Self {
280        Self {
281            location: None,
282            identification: None,
283            name: None,
284            description: None,
285            referenced_document: None,
286        }
287    }
288
289    /// Sets `location`: `Location` (URI) of the reference; at least one of
290    /// location/identification/name must be given.
291    #[must_use]
292    pub fn location(mut self, value: &'a str) -> Self {
293        self.location = Some(value);
294        self
295    }
296
297    /// Sets `identification`: `Identification` code, when stated
298    /// (`ItemReference` in IFC2X3).
299    #[must_use]
300    pub fn identification(mut self, value: &'a str) -> Self {
301        self.identification = Some(value);
302        self
303    }
304
305    /// Sets `name`: `Name`; exactly one of `name` and `referenced_document`
306    /// must be given.
307    #[must_use]
308    pub fn name(mut self, value: &'a str) -> Self {
309        self.name = Some(value);
310        self
311    }
312
313    /// Sets `description`: `Description` of the reference, when stated. IFC4
314    /// onwards.
315    #[must_use]
316    pub fn description(mut self, value: &'a str) -> Self {
317        self.description = Some(value);
318        self
319    }
320
321    /// Sets `referenced_document`: `ReferencedDocument`: an
322    /// `IfcDocumentInformation`; exactly one of `name` and this must be given.
323    /// IFC4 onwards: IFC2X3 links the other way, so there `name` is required.
324    #[must_use]
325    pub fn referenced_document(mut self, value: EntityId) -> Self {
326        self.referenced_document = Some(value);
327        self
328    }
329}
330
331impl<'a> LibraryDraft<'a> {
332    /// Starts a draft from its required fields; every other field is unset.
333    #[must_use]
334    pub fn new(name: &'a str) -> Self {
335        Self {
336            name,
337            version: None,
338            publisher: None,
339            version_date: None,
340            location: None,
341            description: None,
342        }
343    }
344
345    /// Sets `version`: `Version` identifier, when stated.
346    #[must_use]
347    pub fn version(mut self, value: &'a str) -> Self {
348        self.version = Some(value);
349        self
350    }
351
352    /// Sets `publisher`: `Publisher`: an `IfcActorSelect` (only an
353    /// `IfcOrganization` in IFC2X3), when stated.
354    #[must_use]
355    pub fn publisher(mut self, value: EntityId) -> Self {
356        self.publisher = Some(value);
357        self
358    }
359
360    /// Sets `version_date`: `VersionDate` (IFC date-time string), when stated.
361    /// An `IfcCalendarDate` record in IFC2X3.
362    #[must_use]
363    pub fn version_date(mut self, value: &'a str) -> Self {
364        self.version_date = Some(value);
365        self
366    }
367
368    /// Sets `location`: `Location` (URI) of the library, when stated. IFC4
369    /// onwards.
370    #[must_use]
371    pub fn location(mut self, value: &'a str) -> Self {
372        self.location = Some(value);
373        self
374    }
375
376    /// Sets `description`: `Description` of the library, when stated. IFC4
377    /// onwards.
378    #[must_use]
379    pub fn description(mut self, value: &'a str) -> Self {
380        self.description = Some(value);
381        self
382    }
383}
384
385impl<'a> LibraryReferenceDraft<'a> {
386    /// Starts an empty draft; every field is unset.
387    #[must_use]
388    pub fn new() -> Self {
389        Self {
390            location: None,
391            identification: None,
392            name: None,
393            description: None,
394            language: None,
395            referenced_library: None,
396        }
397    }
398
399    /// Sets `location`: `Location` (URI) of the reference; at least one of
400    /// location/identification/name must be given.
401    #[must_use]
402    pub fn location(mut self, value: &'a str) -> Self {
403        self.location = Some(value);
404        self
405    }
406
407    /// Sets `identification`: `Identification` code within the library, when
408    /// stated (`ItemReference` in IFC2X3).
409    #[must_use]
410    pub fn identification(mut self, value: &'a str) -> Self {
411        self.identification = Some(value);
412        self
413    }
414
415    /// Sets `name`: `Name` of the referenced item, when stated.
416    #[must_use]
417    pub fn name(mut self, value: &'a str) -> Self {
418        self.name = Some(value);
419        self
420    }
421
422    /// Sets `description`: `Description` of the reference, when stated. IFC4
423    /// onwards.
424    #[must_use]
425    pub fn description(mut self, value: &'a str) -> Self {
426        self.description = Some(value);
427        self
428    }
429
430    /// Sets `language`: `Language` of the referenced content, when stated. IFC4
431    /// onwards.
432    #[must_use]
433    pub fn language(mut self, value: &'a str) -> Self {
434        self.language = Some(value);
435        self
436    }
437
438    /// Sets `referenced_library`: `ReferencedLibrary`: an
439    /// `IfcLibraryInformation`, when stated. IFC4 onwards.
440    #[must_use]
441    pub fn referenced_library(mut self, value: EntityId) -> Self {
442        self.referenced_library = Some(value);
443        self
444    }
445}
446
447impl<'a> AssociationDraft<'a> {
448    /// Starts a draft from its required fields; every other field is unset.
449    #[must_use]
450    pub fn new(global_id: &'a str, related_objects: &'a [EntityId]) -> Self {
451        Self {
452            global_id,
453            name: None,
454            description: None,
455            related_objects,
456        }
457    }
458
459    /// Sets `name`: `Name` of the relationship, when stated.
460    #[must_use]
461    pub fn name(mut self, value: &'a str) -> Self {
462        self.name = Some(value);
463        self
464    }
465
466    /// Sets `description`: `Description` of the relationship, when stated.
467    #[must_use]
468    pub fn description(mut self, value: &'a str) -> Self {
469        self.description = Some(value);
470        self
471    }
472}