Struct railroad::notactuallysvg::Element
source · pub struct Element { /* private fields */ }
Expand description
A pseudo-SVG Element
use railroad::notactuallysvg as svg;
let e = svg::Element::new("g")
.add(svg::Element::new("rect")
.set("class", "important")
.set("x", &15))
.add(svg::PathData::new(svg::HDir::LTR)
.move_to(5, 5)
.line_rel(10, 20)
.into_path());
let serialized = e.to_string();
assert_eq!(serialized, "<g>\n<rect class=\"important\" x=\"15\"/>\n<path d=\" M 5 5 l 10 20\"/>\n</g>\n");
Implementations§
source§impl Element
impl Element
sourcepub fn new<T>(name: &T) -> Selfwhere
T: ToString + ?Sized,
pub fn new<T>(name: &T) -> Selfwhere T: ToString + ?Sized,
Construct a new Element
of type name
.
sourcepub fn set<K, V>(self, key: &K, value: &V) -> Selfwhere
K: ToString + ?Sized,
V: ToString + ?Sized,
pub fn set<K, V>(self, key: &K, value: &V) -> Selfwhere K: ToString + ?Sized, V: ToString + ?Sized,
Set this Element’s attribute key
to value
sourcepub fn set_all(
self,
iter: impl IntoIterator<Item = (impl ToString, impl ToString)>
) -> Self
pub fn set_all( self, iter: impl IntoIterator<Item = (impl ToString, impl ToString)> ) -> Self
Set all attributes via these key
:value
-pairs
sourcepub fn text(self, text: &str) -> Self
pub fn text(self, text: &str) -> Self
Set the text within the opening and closing tag of this Element.
The text is automatically HTML-escaped. It is written before any children.
sourcepub fn raw_text<T>(self, text: &T) -> Selfwhere
T: ToString + ?Sized,
pub fn raw_text<T>(self, text: &T) -> Selfwhere T: ToString + ?Sized,
Set the text within the opening and closing tag of this Element.
The text is NOT automatically HTML-escaped.
sourcepub fn add(self, e: Self) -> Self
pub fn add(self, e: Self) -> Self
Add a child to this Element
Children is written within the opening and closing tag of this Element.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
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