Struct Id

Source
pub struct Id(/* private fields */);

Implementations§

Source§

impl Id

Source

pub fn create<S>(id: S) -> Result<Id, InvalidId>
where S: Into<String>,

Examples found in repository?
examples/semantic.rs (line 27)
12fn main() {
13    let title = Some(Text::create("Title"));
14    let styles = vec![];
15    let url = Url::absolute_unchecked("http://google.com".into());
16    let script = Script::External(url);
17    let scripts = vec![script];
18    let head = Head {
19        title,
20        styles,
21        scripts,
22    };
23    let content = vec![Text::create("Hello").into()];
24    let body = Body {
25        content,
26        scripts: vec![],
27        id: Some(Id::create("my-id").unwrap()),
28        class: vec![
29            Class::create("test").unwrap(),
30            Class::create("body").unwrap(),
31        ],
32    };
33    let html = Html {
34        head,
35        body,
36        lang: Value::EN,
37    };
38    let doc = Document { html };
39    let string: String = doc.into();
40
41    println!("{}", string);
42}

Trait Implementations§

Source§

impl<'a> From<Id> for Value<'a>

Source§

fn from(value: Id) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Id

§

impl RefUnwindSafe for Id

§

impl Send for Id

§

impl Sync for Id

§

impl Unpin for Id

§

impl UnwindSafe for Id

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.