Struct Value

Source
pub struct Value<'a>(/* private fields */);

Implementations§

Source§

impl<'a> Value<'a>

Source

pub const TEXT_CSS: Value<'static>

Source

pub const STYLESHEET: Value<'static>

Source

pub const UTF_8: Value<'static>

Source

pub const EN: Value<'static>

Source

pub fn is_valid(str: &str) -> bool

Function that determines whether a string slice would be considered a valid value. Can be helpful elsewhere when specifing more restrictive types

Source

pub fn create(str: &'a str) -> Result<Value<'a>, InvalidValueError>

Examples found in repository?
examples/simple.rs (line 13)
9fn main() {
10    // Create a link
11    let link = {
12        let label = Text::create("Click Me");
13        let url = Value::create("http://google.com").unwrap();
14        // Anchor is a helper for the typical case
15        Element::anchor(url, label)
16    };
17    // Create the body. Sugar function takes a list of child nodes
18    let body = Element::body(vec![link]);
19
20    // Create a header manually. There isn't a sugar function here
21    let header = {
22        let mut el = Element::<Vec<Node>>::create(Tag::HEADER);
23        let text = Text::create("Hello world");
24        let title = Element::title(text);
25        el.push(title);
26        el
27    };
28    let html = Element::html(Value::EN, header, body);
29
30    // Convert an element into a node
31    let node: Node = html.into();
32
33    // Nodes can be turned into HTML formatted strings
34    let string: String = node.into();
35
36    println!("{}", string);
37}
Source

pub fn owned<S>(str: S) -> Result<Value<'a>, InvalidValueError>
where S: Into<String>,

Trait Implementations§

Source§

impl<'a> Clone for Value<'a>

Source§

fn clone(&self) -> Value<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Value<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Display for Value<'a>

Source§

fn fmt(&self, _derive_more_display_formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

fn from(value: Id) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(value: Url) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for Value<'a>

Source§

fn eq(&self, other: &Value<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<Vec<Class>> for Value<'a>

Source§

type Error = EmptyVector

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

fn try_from(value: Vec<Class>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> Eq for Value<'a>

Source§

impl<'a> StructuralPartialEq for Value<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Value<'a>

§

impl<'a> RefUnwindSafe for Value<'a>

§

impl<'a> Send for Value<'a>

§

impl<'a> Sync for Value<'a>

§

impl<'a> Unpin for Value<'a>

§

impl<'a> UnwindSafe for Value<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.