html/generated/
base.rs

1pub mod element {
2    /// The HTML `<base>` element
3    ///
4    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base)
5    #[doc(alias = "base")]
6    #[non_exhaustive]
7    #[derive(PartialEq, Clone, Default)]
8    pub struct Base {
9        sys: html_sys::metadata::Base,
10    }
11    impl Base {
12        /// Create a new builder
13        pub fn builder() -> super::builder::BaseBuilder {
14            super::builder::BaseBuilder::new(Default::default())
15        }
16    }
17    impl Base {
18        /// Access the element's `data-*` properties
19        pub fn data_map(&self) -> &html_sys::DataMap {
20            &self.sys.data_map
21        }
22        /// Mutably access the element's `data-*` properties
23        pub fn data_map_mut(&mut self) -> &mut html_sys::DataMap {
24            &mut self.sys.data_map
25        }
26    }
27    impl Base {
28        /// Get the value of the `href` attribute
29        pub fn href(&self) -> std::option::Option<&str> {
30            self.sys.href.as_deref()
31        }
32        /// Set the value of the `href` attribute
33        pub fn set_href(
34            &mut self,
35            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
36        ) {
37            self.sys.href = value.map(|v| v.into());
38        }
39        /// Get the value of the `target` attribute
40        pub fn target(&self) -> std::option::Option<&str> {
41            self.sys.target.as_deref()
42        }
43        /// Set the value of the `target` attribute
44        pub fn set_target(
45            &mut self,
46            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
47        ) {
48            self.sys.target = value.map(|v| v.into());
49        }
50        /// Get the value of the `accesskey` attribute
51        pub fn access_key(&self) -> std::option::Option<&str> {
52            self.sys.access_key.as_deref()
53        }
54        /// Set the value of the `accesskey` attribute
55        pub fn set_access_key(
56            &mut self,
57            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
58        ) {
59            self.sys.access_key = value.map(|v| v.into());
60        }
61        /// Get the value of the `autocapitalize` attribute
62        pub fn auto_capitalize(&self) -> std::option::Option<&str> {
63            self.sys.auto_capitalize.as_deref()
64        }
65        /// Set the value of the `autocapitalize` attribute
66        pub fn set_auto_capitalize(
67            &mut self,
68            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
69        ) {
70            self.sys.auto_capitalize = value.map(|v| v.into());
71        }
72        /// Get the value of the `autofocus` attribute
73        pub fn autofocus(&self) -> bool {
74            self.sys.autofocus
75        }
76        /// Set the value of the `autofocus` attribute
77        pub fn set_autofocus(&mut self, value: bool) {
78            self.sys.autofocus = value;
79        }
80        /// Get the value of the `class` attribute
81        pub fn class(&self) -> std::option::Option<&str> {
82            self.sys.class.as_deref()
83        }
84        /// Set the value of the `class` attribute
85        pub fn set_class(
86            &mut self,
87            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
88        ) {
89            self.sys.class = value.map(|v| v.into());
90        }
91        /// Get the value of the `contenteditable` attribute
92        pub fn content_editable(&self) -> std::option::Option<&str> {
93            self.sys.content_editable.as_deref()
94        }
95        /// Set the value of the `contenteditable` attribute
96        pub fn set_content_editable(
97            &mut self,
98            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
99        ) {
100            self.sys.content_editable = value.map(|v| v.into());
101        }
102        /// Get the value of the `dir` attribute
103        pub fn direction(&self) -> std::option::Option<&str> {
104            self.sys.direction.as_deref()
105        }
106        /// Set the value of the `dir` attribute
107        pub fn set_direction(
108            &mut self,
109            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
110        ) {
111            self.sys.direction = value.map(|v| v.into());
112        }
113        /// Get the value of the `draggable` attribute
114        pub fn draggable(&self) -> bool {
115            self.sys.draggable
116        }
117        /// Set the value of the `draggable` attribute
118        pub fn set_draggable(&mut self, value: bool) {
119            self.sys.draggable = value;
120        }
121        /// Get the value of the `enterkeyhint` attribute
122        pub fn enter_key_hint(&self) -> std::option::Option<&str> {
123            self.sys.enter_key_hint.as_deref()
124        }
125        /// Set the value of the `enterkeyhint` attribute
126        pub fn set_enter_key_hint(
127            &mut self,
128            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
129        ) {
130            self.sys.enter_key_hint = value.map(|v| v.into());
131        }
132        /// Get the value of the `exportparts` attribute
133        pub fn export_parts(&self) -> std::option::Option<&str> {
134            self.sys.export_parts.as_deref()
135        }
136        /// Set the value of the `exportparts` attribute
137        pub fn set_export_parts(
138            &mut self,
139            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
140        ) {
141            self.sys.export_parts = value.map(|v| v.into());
142        }
143        /// Get the value of the `hidden` attribute
144        pub fn hidden(&self) -> std::option::Option<&str> {
145            self.sys.hidden.as_deref()
146        }
147        /// Set the value of the `hidden` attribute
148        pub fn set_hidden(
149            &mut self,
150            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
151        ) {
152            self.sys.hidden = value.map(|v| v.into());
153        }
154        /// Get the value of the `id` attribute
155        pub fn id(&self) -> std::option::Option<&str> {
156            self.sys.id.as_deref()
157        }
158        /// Set the value of the `id` attribute
159        pub fn set_id(
160            &mut self,
161            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
162        ) {
163            self.sys.id = value.map(|v| v.into());
164        }
165        /// Get the value of the `inert` attribute
166        pub fn inert(&self) -> bool {
167            self.sys.inert
168        }
169        /// Set the value of the `inert` attribute
170        pub fn set_inert(&mut self, value: bool) {
171            self.sys.inert = value;
172        }
173        /// Get the value of the `inputmode` attribute
174        pub fn input_mode(&self) -> std::option::Option<&str> {
175            self.sys.input_mode.as_deref()
176        }
177        /// Set the value of the `inputmode` attribute
178        pub fn set_input_mode(
179            &mut self,
180            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
181        ) {
182            self.sys.input_mode = value.map(|v| v.into());
183        }
184        /// Get the value of the `is` attribute
185        pub fn is_(&self) -> std::option::Option<&str> {
186            self.sys.is_.as_deref()
187        }
188        /// Set the value of the `is` attribute
189        pub fn set_is_(
190            &mut self,
191            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
192        ) {
193            self.sys.is_ = value.map(|v| v.into());
194        }
195        /// Get the value of the `itemid` attribute
196        pub fn item_id(&self) -> std::option::Option<&str> {
197            self.sys.item_id.as_deref()
198        }
199        /// Set the value of the `itemid` attribute
200        pub fn set_item_id(
201            &mut self,
202            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
203        ) {
204            self.sys.item_id = value.map(|v| v.into());
205        }
206        /// Get the value of the `itemprop` attribute
207        pub fn item_prop(&self) -> std::option::Option<&str> {
208            self.sys.item_prop.as_deref()
209        }
210        /// Set the value of the `itemprop` attribute
211        pub fn set_item_prop(
212            &mut self,
213            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
214        ) {
215            self.sys.item_prop = value.map(|v| v.into());
216        }
217        /// Get the value of the `itemref` attribute
218        pub fn item_ref(&self) -> std::option::Option<&str> {
219            self.sys.item_ref.as_deref()
220        }
221        /// Set the value of the `itemref` attribute
222        pub fn set_item_ref(
223            &mut self,
224            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
225        ) {
226            self.sys.item_ref = value.map(|v| v.into());
227        }
228        /// Get the value of the `itemscope` attribute
229        pub fn item_scope(&self) -> std::option::Option<&str> {
230            self.sys.item_scope.as_deref()
231        }
232        /// Set the value of the `itemscope` attribute
233        pub fn set_item_scope(
234            &mut self,
235            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
236        ) {
237            self.sys.item_scope = value.map(|v| v.into());
238        }
239        /// Get the value of the `itemtype` attribute
240        pub fn item_type(&self) -> std::option::Option<&str> {
241            self.sys.item_type.as_deref()
242        }
243        /// Set the value of the `itemtype` attribute
244        pub fn set_item_type(
245            &mut self,
246            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
247        ) {
248            self.sys.item_type = value.map(|v| v.into());
249        }
250        /// Get the value of the `lang` attribute
251        pub fn lang(&self) -> std::option::Option<&str> {
252            self.sys.lang.as_deref()
253        }
254        /// Set the value of the `lang` attribute
255        pub fn set_lang(
256            &mut self,
257            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
258        ) {
259            self.sys.lang = value.map(|v| v.into());
260        }
261        /// Get the value of the `nonce` attribute
262        pub fn nonce(&self) -> std::option::Option<&str> {
263            self.sys.nonce.as_deref()
264        }
265        /// Set the value of the `nonce` attribute
266        pub fn set_nonce(
267            &mut self,
268            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
269        ) {
270            self.sys.nonce = value.map(|v| v.into());
271        }
272        /// Get the value of the `part` attribute
273        pub fn part(&self) -> std::option::Option<&str> {
274            self.sys.part.as_deref()
275        }
276        /// Set the value of the `part` attribute
277        pub fn set_part(
278            &mut self,
279            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
280        ) {
281            self.sys.part = value.map(|v| v.into());
282        }
283        /// Get the value of the `slot` attribute
284        pub fn slot(&self) -> std::option::Option<&str> {
285            self.sys.slot.as_deref()
286        }
287        /// Set the value of the `slot` attribute
288        pub fn set_slot(
289            &mut self,
290            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
291        ) {
292            self.sys.slot = value.map(|v| v.into());
293        }
294        /// Get the value of the `spellcheck` attribute
295        pub fn spellcheck(&self) -> std::option::Option<&str> {
296            self.sys.spellcheck.as_deref()
297        }
298        /// Set the value of the `spellcheck` attribute
299        pub fn set_spellcheck(
300            &mut self,
301            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
302        ) {
303            self.sys.spellcheck = value.map(|v| v.into());
304        }
305        /// Get the value of the `style` attribute
306        pub fn style(&self) -> std::option::Option<&str> {
307            self.sys.style.as_deref()
308        }
309        /// Set the value of the `style` attribute
310        pub fn set_style(
311            &mut self,
312            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
313        ) {
314            self.sys.style = value.map(|v| v.into());
315        }
316        /// Get the value of the `tabindex` attribute
317        pub fn tab_index(&self) -> std::option::Option<i64> {
318            self.sys.tab_index
319        }
320        /// Set the value of the `tabindex` attribute
321        pub fn set_tab_index(&mut self, value: std::option::Option<i64>) {
322            self.sys.tab_index = value;
323        }
324        /// Get the value of the `title` attribute
325        pub fn title(&self) -> std::option::Option<&str> {
326            self.sys.title.as_deref()
327        }
328        /// Set the value of the `title` attribute
329        pub fn set_title(
330            &mut self,
331            value: std::option::Option<impl Into<std::borrow::Cow<'static, str>>>,
332        ) {
333            self.sys.title = value.map(|v| v.into());
334        }
335        /// Get the value of the `translate` attribute
336        pub fn translate(&self) -> bool {
337            self.sys.translate
338        }
339        /// Set the value of the `translate` attribute
340        pub fn set_translate(&mut self, value: bool) {
341            self.sys.translate = value;
342        }
343    }
344    impl crate::Render for Base {
345        fn render(
346            &self,
347            f: &mut std::fmt::Formatter<'_>,
348            depth: usize,
349        ) -> std::fmt::Result {
350            write!(f, "{:level$}", "", level = depth * 4)?;
351            html_sys::RenderElement::write_opening_tag(&self.sys, f)?;
352            Ok(())
353        }
354    }
355    impl std::fmt::Debug for Base {
356        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
357            crate::Render::render(self, f, 0)?;
358            Ok(())
359        }
360    }
361    impl std::fmt::Display for Base {
362        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
363            html_sys::RenderElement::write_opening_tag(&self.sys, f)?;
364            html_sys::RenderElement::write_closing_tag(&self.sys, f)?;
365            Ok(())
366        }
367    }
368    impl crate::HtmlElement for Base {}
369    impl crate::MetadataContent for Base {}
370    impl std::convert::Into<html_sys::metadata::Base> for Base {
371        fn into(self) -> html_sys::metadata::Base {
372            self.sys
373        }
374    }
375    impl From<html_sys::metadata::Base> for Base {
376        fn from(sys: html_sys::metadata::Base) -> Self {
377            Self { sys }
378        }
379    }
380}
381pub mod child {}
382pub mod builder {
383    /// A builder struct for Base
384    pub struct BaseBuilder {
385        element: super::element::Base,
386    }
387    impl BaseBuilder {
388        pub(crate) fn new(element: super::element::Base) -> Self {
389            Self { element }
390        }
391        /// Finish building the element
392        pub fn build(&mut self) -> super::element::Base {
393            self.element.clone()
394        }
395        /// Insert a `data-*` property
396        pub fn data(
397            &mut self,
398            data_key: impl Into<std::borrow::Cow<'static, str>>,
399            value: impl Into<std::borrow::Cow<'static, str>>,
400        ) -> &mut BaseBuilder {
401            self.element.data_map_mut().insert(data_key.into(), value.into());
402            self
403        }
404        /// Set the value of the `href` attribute
405        pub fn href(
406            &mut self,
407            value: impl Into<std::borrow::Cow<'static, str>>,
408        ) -> &mut Self {
409            self.element.set_href(Some(value.into()));
410            self
411        }
412        /// Set the value of the `target` attribute
413        pub fn target(
414            &mut self,
415            value: impl Into<std::borrow::Cow<'static, str>>,
416        ) -> &mut Self {
417            self.element.set_target(Some(value.into()));
418            self
419        }
420        /// Set the value of the `accesskey` attribute
421        pub fn access_key(
422            &mut self,
423            value: impl Into<std::borrow::Cow<'static, str>>,
424        ) -> &mut Self {
425            self.element.set_access_key(Some(value.into()));
426            self
427        }
428        /// Set the value of the `autocapitalize` attribute
429        pub fn auto_capitalize(
430            &mut self,
431            value: impl Into<std::borrow::Cow<'static, str>>,
432        ) -> &mut Self {
433            self.element.set_auto_capitalize(Some(value.into()));
434            self
435        }
436        /// Set the value of the `autofocus` attribute
437        pub fn autofocus(&mut self, value: bool) -> &mut Self {
438            self.element.set_autofocus(value);
439            self
440        }
441        /// Set the value of the `class` attribute
442        pub fn class(
443            &mut self,
444            value: impl Into<std::borrow::Cow<'static, str>>,
445        ) -> &mut Self {
446            self.element.set_class(Some(value.into()));
447            self
448        }
449        /// Set the value of the `contenteditable` attribute
450        pub fn content_editable(
451            &mut self,
452            value: impl Into<std::borrow::Cow<'static, str>>,
453        ) -> &mut Self {
454            self.element.set_content_editable(Some(value.into()));
455            self
456        }
457        /// Set the value of the `dir` attribute
458        pub fn direction(
459            &mut self,
460            value: impl Into<std::borrow::Cow<'static, str>>,
461        ) -> &mut Self {
462            self.element.set_direction(Some(value.into()));
463            self
464        }
465        /// Set the value of the `draggable` attribute
466        pub fn draggable(&mut self, value: bool) -> &mut Self {
467            self.element.set_draggable(value);
468            self
469        }
470        /// Set the value of the `enterkeyhint` attribute
471        pub fn enter_key_hint(
472            &mut self,
473            value: impl Into<std::borrow::Cow<'static, str>>,
474        ) -> &mut Self {
475            self.element.set_enter_key_hint(Some(value.into()));
476            self
477        }
478        /// Set the value of the `exportparts` attribute
479        pub fn export_parts(
480            &mut self,
481            value: impl Into<std::borrow::Cow<'static, str>>,
482        ) -> &mut Self {
483            self.element.set_export_parts(Some(value.into()));
484            self
485        }
486        /// Set the value of the `hidden` attribute
487        pub fn hidden(
488            &mut self,
489            value: impl Into<std::borrow::Cow<'static, str>>,
490        ) -> &mut Self {
491            self.element.set_hidden(Some(value.into()));
492            self
493        }
494        /// Set the value of the `id` attribute
495        pub fn id(
496            &mut self,
497            value: impl Into<std::borrow::Cow<'static, str>>,
498        ) -> &mut Self {
499            self.element.set_id(Some(value.into()));
500            self
501        }
502        /// Set the value of the `inert` attribute
503        pub fn inert(&mut self, value: bool) -> &mut Self {
504            self.element.set_inert(value);
505            self
506        }
507        /// Set the value of the `inputmode` attribute
508        pub fn input_mode(
509            &mut self,
510            value: impl Into<std::borrow::Cow<'static, str>>,
511        ) -> &mut Self {
512            self.element.set_input_mode(Some(value.into()));
513            self
514        }
515        /// Set the value of the `is` attribute
516        pub fn is_(
517            &mut self,
518            value: impl Into<std::borrow::Cow<'static, str>>,
519        ) -> &mut Self {
520            self.element.set_is_(Some(value.into()));
521            self
522        }
523        /// Set the value of the `itemid` attribute
524        pub fn item_id(
525            &mut self,
526            value: impl Into<std::borrow::Cow<'static, str>>,
527        ) -> &mut Self {
528            self.element.set_item_id(Some(value.into()));
529            self
530        }
531        /// Set the value of the `itemprop` attribute
532        pub fn item_prop(
533            &mut self,
534            value: impl Into<std::borrow::Cow<'static, str>>,
535        ) -> &mut Self {
536            self.element.set_item_prop(Some(value.into()));
537            self
538        }
539        /// Set the value of the `itemref` attribute
540        pub fn item_ref(
541            &mut self,
542            value: impl Into<std::borrow::Cow<'static, str>>,
543        ) -> &mut Self {
544            self.element.set_item_ref(Some(value.into()));
545            self
546        }
547        /// Set the value of the `itemscope` attribute
548        pub fn item_scope(
549            &mut self,
550            value: impl Into<std::borrow::Cow<'static, str>>,
551        ) -> &mut Self {
552            self.element.set_item_scope(Some(value.into()));
553            self
554        }
555        /// Set the value of the `itemtype` attribute
556        pub fn item_type(
557            &mut self,
558            value: impl Into<std::borrow::Cow<'static, str>>,
559        ) -> &mut Self {
560            self.element.set_item_type(Some(value.into()));
561            self
562        }
563        /// Set the value of the `lang` attribute
564        pub fn lang(
565            &mut self,
566            value: impl Into<std::borrow::Cow<'static, str>>,
567        ) -> &mut Self {
568            self.element.set_lang(Some(value.into()));
569            self
570        }
571        /// Set the value of the `nonce` attribute
572        pub fn nonce(
573            &mut self,
574            value: impl Into<std::borrow::Cow<'static, str>>,
575        ) -> &mut Self {
576            self.element.set_nonce(Some(value.into()));
577            self
578        }
579        /// Set the value of the `part` attribute
580        pub fn part(
581            &mut self,
582            value: impl Into<std::borrow::Cow<'static, str>>,
583        ) -> &mut Self {
584            self.element.set_part(Some(value.into()));
585            self
586        }
587        /// Set the value of the `slot` attribute
588        pub fn slot(
589            &mut self,
590            value: impl Into<std::borrow::Cow<'static, str>>,
591        ) -> &mut Self {
592            self.element.set_slot(Some(value.into()));
593            self
594        }
595        /// Set the value of the `spellcheck` attribute
596        pub fn spellcheck(
597            &mut self,
598            value: impl Into<std::borrow::Cow<'static, str>>,
599        ) -> &mut Self {
600            self.element.set_spellcheck(Some(value.into()));
601            self
602        }
603        /// Set the value of the `style` attribute
604        pub fn style(
605            &mut self,
606            value: impl Into<std::borrow::Cow<'static, str>>,
607        ) -> &mut Self {
608            self.element.set_style(Some(value.into()));
609            self
610        }
611        /// Set the value of the `tabindex` attribute
612        pub fn tab_index(&mut self, value: i64) -> &mut Self {
613            self.element.set_tab_index(Some(value));
614            self
615        }
616        /// Set the value of the `title` attribute
617        pub fn title(
618            &mut self,
619            value: impl Into<std::borrow::Cow<'static, str>>,
620        ) -> &mut Self {
621            self.element.set_title(Some(value.into()));
622            self
623        }
624        /// Set the value of the `translate` attribute
625        pub fn translate(&mut self, value: bool) -> &mut Self {
626            self.element.set_translate(value);
627            self
628        }
629    }
630}