pub struct Value<'a>(/* private fields */);
Implementations§
Source§impl<'a> Value<'a>
impl<'a> Value<'a>
pub const TEXT_CSS: Value<'static>
pub const STYLESHEET: Value<'static>
pub const UTF_8: Value<'static>
pub const EN: Value<'static>
Sourcepub fn is_valid(str: &str) -> bool
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
Sourcepub fn create(str: &'a str) -> Result<Value<'a>, InvalidValueError>
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}
pub fn owned<S>(str: S) -> Result<Value<'a>, InvalidValueError>
Trait Implementations§
impl<'a> Eq for Value<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more