cabin/html/elements/
source.rs1use std::borrow::Cow;
2
3use super::global::Global;
4use super::img::{Sizes, SrcSet};
5use super::input::{Height, Width};
6use super::link::Type;
7use super::meta::Media;
8use super::script::Src;
9use crate::html::attributes::{Attributes, WithAttribute};
10use crate::html::Html;
11
12pub fn source() -> Html<marker::Source, (), ()> {
16 Html::new("source", (), ())
17}
18
19pub mod marker {
20 pub struct Source;
21}
22
23impl<A: Attributes, V: 'static> Source for Html<marker::Source, A, V> {}
24impl<A: Attributes, V: 'static> Global for Html<marker::Source, A, V> {}
25
26pub trait Source: WithAttribute {
28 fn r#type(self, r#type: impl Into<Cow<'static, str>>) -> Self::Output<Type> {
30 self.with_attribute(Type(r#type.into()))
31 }
32
33 fn media(self, media: impl Into<Cow<'static, str>>) -> Self::Output<Media> {
35 self.with_attribute(Media(media.into()))
36 }
37
38 fn src(self, src: impl Into<Cow<'static, str>>) -> Self::Output<Src> {
40 self.with_attribute(Src(src.into()))
41 }
42
43 fn src_set(self, src_set: impl Into<Cow<'static, str>>) -> Self::Output<SrcSet> {
45 self.with_attribute(SrcSet(src_set.into()))
46 }
47
48 fn sizes(self, sizes: impl Into<Cow<'static, str>>) -> Self::Output<Sizes> {
50 self.with_attribute(Sizes(sizes.into()))
51 }
52
53 fn height(self, height: u32) -> Self::Output<Height> {
55 self.with_attribute(Height(height))
56 }
57
58 fn width(self, width: u32) -> Self::Output<Width> {
60 self.with_attribute(Width(width))
61 }
62}