pub struct Diagram<T: RailroadNode> { /* private fields */ }
Implementations
sourceimpl<T: RailroadNode> Diagram<T>
impl<T: RailroadNode> Diagram<T>
sourcepub fn new(root: T) -> Self
pub fn new(root: T) -> Self
Create a diagram using the given root-element.
let mut seq = railroad::Sequence::default();
seq.push(Box::new(railroad::Start))
.push(Box::new(railroad::Terminal::new("Foobar".to_owned())))
.push(Box::new(railroad::End));
let mut dia = railroad::Diagram::new(seq);
dia.add_element(railroad::svg::Element::new("style")
.set("type", "text/css")
.raw_text(railroad::DEFAULT_CSS));
println!("{}", dia);
sourcepub fn with_default_css(root: T) -> Self
pub fn with_default_css(root: T) -> Self
Create a diagram which has this library’s default CSS style included.
sourcepub fn add_default_css(&mut self)
pub fn add_default_css(&mut self)
Add the default CSS as an additional <style>
element.
sourcepub fn set_attribute(
&mut self,
key: impl Into<String>,
value: impl ToString
) -> &mut Self
pub fn set_attribute(
&mut self,
key: impl Into<String>,
value: impl ToString
) -> &mut Self
Set an attribute on the
sourcepub fn add_element(&mut self, e: Element) -> &mut Self
pub fn add_element(&mut self, e: Element) -> &mut Self
Add an additional svg::Element
which is written before the root-element
pub fn write(&self, writer: &mut impl Write) -> Result<()>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Return the root-element this diagram’s root element
Trait Implementations
sourceimpl<T: Debug + RailroadNode> Debug for Diagram<T>
impl<T: Debug + RailroadNode> Debug for Diagram<T>
sourceimpl<T: RailroadNode> Display for Diagram<T>
impl<T: RailroadNode> Display for Diagram<T>
sourceimpl<T: RailroadNode> RailroadNode for Diagram<T>
impl<T: RailroadNode> RailroadNode for Diagram<T>
sourcefn entry_height(&self) -> i64
fn entry_height(&self) -> i64
The vertical distance from this element’s top to where the entering,
connecting path is drawn. Read more
sourcefn height_below_entry(&self) -> i64
fn height_below_entry(&self) -> i64
The vertical distance from the height of the connecting path to the bottom.
Auto Trait Implementations
impl<T> RefUnwindSafe for Diagram<T>where
T: RefUnwindSafe,
impl<T> Send for Diagram<T>where
T: Send,
impl<T> Sync for Diagram<T>where
T: Sync,
impl<T> Unpin for Diagram<T>where
T: Unpin,
impl<T> UnwindSafe for Diagram<T>where
T: UnwindSafe,
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