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
sourceimpl Element
impl Element
sourcepub fn set(self, key: impl Into<String>, value: impl ToString) -> Self
pub fn set(self, key: impl Into<String>, value: impl ToString) -> Self
Set this Element’s attribute key
to value
sourcepub fn set_all<'a>(
self,
iter: impl IntoIterator<Item = (&'a String, &'a String)>
) -> Self
pub fn set_all<'a>(
self,
iter: impl IntoIterator<Item = (&'a String, &'a String)>
) -> 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(self, text: impl Into<String>) -> Self
pub fn raw_text(self, text: impl Into<String>) -> Self
Set the text within the opening and closing tag of this Element.
The text is NOT automatically HTML-escaped.
sourcepub fn add(self, e: Element) -> Self
pub fn add(self, e: Element) -> 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more