cabin/html/elements/
object.rs1use std::borrow::Cow;
2
3use cabin_macros::Attribute;
4
5use super::button::Form;
6use super::common::Common;
7use super::global::Global;
8use super::iframe::Name;
9use super::input::{Height, Width};
10use super::link::Type;
11use crate::html::attributes::{Attributes, WithAttribute};
12use crate::html::{Aria, Html};
13use crate::View;
14
15pub fn object(content: impl View) -> Html<marker::Object, (), impl View> {
18 #[cfg(debug_assertions)]
19 let content = content.boxed();
20 Html::new("object", (), content)
21}
22
23pub mod marker {
24 pub struct Object;
25}
26
27impl<A: Attributes, V: 'static> Object for Html<marker::Object, A, V> {}
28impl<A: Attributes, V: 'static> Common for Html<marker::Object, A, V> {}
29impl<A: Attributes, V: 'static> Global for Html<marker::Object, A, V> {}
30impl<A: Attributes, V: 'static> Aria for Html<marker::Object, A, V> {}
31
32pub trait Object: WithAttribute {
35 fn data(self, data: impl Into<Cow<'static, str>>) -> Self::Output<Data> {
37 self.with_attribute(Data(data.into()))
38 }
39
40 fn r#type(self, r#type: impl Into<Cow<'static, str>>) -> Self::Output<Type> {
42 self.with_attribute(Type(r#type.into()))
43 }
44
45 fn name(self, name: impl Into<Cow<'static, str>>) -> Self::Output<Name> {
47 self.with_attribute(Name(name.into()))
48 }
49
50 fn form(self, form: impl Into<Cow<'static, str>>) -> Self::Output<Form> {
52 self.with_attribute(Form(form.into()))
53 }
54
55 fn width(self, width: u32) -> Self::Output<Width> {
57 self.with_attribute(Width(width))
58 }
59
60 fn height(self, height: u32) -> Self::Output<Height> {
62 self.with_attribute(Height(height))
63 }
64}
65
66#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Attribute)]
68pub struct Data(pub Cow<'static, str>);