Skip to main content

ifc_style/authoring/external/
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> BlobTextureDraft<'a> {
8    /// Starts a draft from its required `raster_format`, `raster_code`; every
9    /// other field is unset.
10    #[must_use]
11    pub fn new(raster_format: &'a str, raster_code: &'a str) -> Self {
12        Self {
13            repeat_s: false,
14            repeat_t: false,
15            mode: None,
16            texture_transform: None,
17            parameter: &[],
18            raster_format,
19            raster_code,
20        }
21    }
22
23    /// Sets `repeat_s`.
24    ///
25    /// `RepeatS`: whether the texture tiles along S.
26    #[must_use]
27    pub fn repeat_s(mut self, value: bool) -> Self {
28        self.repeat_s = value;
29        self
30    }
31
32    /// Sets `repeat_t`.
33    ///
34    /// `RepeatT`: whether the texture tiles along T.
35    #[must_use]
36    pub fn repeat_t(mut self, value: bool) -> Self {
37        self.repeat_t = value;
38        self
39    }
40
41    /// Sets `mode`.
42    ///
43    /// `Mode`: the texture application mode.
44    #[must_use]
45    pub fn mode(mut self, value: &'a str) -> Self {
46        self.mode = Some(value);
47        self
48    }
49
50    /// Sets `texture_transform`.
51    ///
52    /// `TextureTransform`: a 2D operator applied to the coordinates.
53    #[must_use]
54    pub fn texture_transform(mut self, value: EntityId) -> Self {
55        self.texture_transform = Some(value);
56        self
57    }
58
59    /// Sets `parameter`.
60    ///
61    /// `Parameter`: optional, but non-empty when present.
62    #[must_use]
63    pub fn parameter(mut self, value: &'a [&'a str]) -> Self {
64        self.parameter = value;
65        self
66    }
67}
68
69impl<'a> TextModelDraft<'a> {
70    /// Starts a draft with every field unset.
71    #[must_use]
72    pub fn new() -> Self {
73        Self::default()
74    }
75
76    /// Sets `text_indent`.
77    ///
78    /// `TextIndent`.
79    #[must_use]
80    pub fn text_indent(mut self, value: SizeValue<'a>) -> Self {
81        self.text_indent = Some(value);
82        self
83    }
84
85    /// Sets `text_align`.
86    ///
87    /// `TextAlign`, one of the closed lower-case alignment words.
88    #[must_use]
89    pub fn text_align(mut self, value: &'a str) -> Self {
90        self.text_align = Some(value);
91        self
92    }
93
94    /// Sets `text_decoration`.
95    ///
96    /// `TextDecoration`, one of the closed lower-case decoration words.
97    #[must_use]
98    pub fn text_decoration(mut self, value: &'a str) -> Self {
99        self.text_decoration = Some(value);
100        self
101    }
102
103    /// Sets `letter_spacing`.
104    ///
105    /// `LetterSpacing`.
106    #[must_use]
107    pub fn letter_spacing(mut self, value: SizeValue<'a>) -> Self {
108        self.letter_spacing = Some(value);
109        self
110    }
111
112    /// Sets `word_spacing`.
113    ///
114    /// `WordSpacing`.
115    #[must_use]
116    pub fn word_spacing(mut self, value: SizeValue<'a>) -> Self {
117        self.word_spacing = Some(value);
118        self
119    }
120
121    /// Sets `text_transform`.
122    ///
123    /// `TextTransform`, one of the closed lower-case transform words.
124    #[must_use]
125    pub fn text_transform(mut self, value: &'a str) -> Self {
126        self.text_transform = Some(value);
127        self
128    }
129
130    /// Sets `line_height`.
131    ///
132    /// `LineHeight`.
133    #[must_use]
134    pub fn line_height(mut self, value: SizeValue<'a>) -> Self {
135        self.line_height = Some(value);
136        self
137    }
138}