pub struct Figure { /* private fields */ }
Expand description
An encapsulation of everything to form a Digital Timing Diagram
There are two ways to utilize Figure
.
- Utilzing
Figure::new
and the builder pattern. - Utilizing
Figure::with
and defining all parameters.
Examples
use std::fs::File;
use wavedrom::{Figure, Signal, CycleState};
let figure = Figure::new()
.header_text("Hello World!")
.footer_text("Bye World!")
.add_signals([
Signal::repeated(CycleState::X, 8),
Signal::repeated(CycleState::Box2, 7),
Signal::repeated(CycleState::Box3, 9),
Signal::repeated(CycleState::Box4, 4),
]);
let assembled_figure = figure.assemble();
let path = "path/to/file.svg";
let mut file = File::create(path)?;
assembled_figure.write_svg(&mut file)?;
Result:
Implementations§
source§impl Figure
impl Figure
sourcepub fn with(
title: Option<String>,
footer: Option<String>,
top_cycle_marker: Option<CycleEnumerationMarker>,
bottom_cycle_marker: Option<CycleEnumerationMarker>,
hscale: u16,
sections: Vec<FigureSection>,
edges: Vec<EdgeDefinition>
) -> Self
pub fn with( title: Option<String>, footer: Option<String>, top_cycle_marker: Option<CycleEnumerationMarker>, bottom_cycle_marker: Option<CycleEnumerationMarker>, hscale: u16, sections: Vec<FigureSection>, edges: Vec<EdgeDefinition> ) -> Self
Create a new Figure
with a set of parameters.
sourcepub fn header_text(self, header_text: impl Into<String>) -> Self
pub fn header_text(self, header_text: impl Into<String>) -> Self
Give a header text to the Figure
.
Give a footer text to the Figure
.
sourcepub fn top_cycle_marker(self, start: u32, every: u32) -> Self
pub fn top_cycle_marker(self, start: u32, every: u32) -> Self
Give a top cycle enumeration marker to the figure with starting with clock cycle start
and displaying one marker every every
th cycle.
sourcepub fn bottom_cycle_marker(self, start: u32, every: u32) -> Self
pub fn bottom_cycle_marker(self, start: u32, every: u32) -> Self
Give a bottom cycle enumeration marker to the figure with starting with clock cycle start
and displaying one marker every every
th cycle.
sourcepub fn horizontal_scale(self, hscale: u16) -> Self
pub fn horizontal_scale(self, hscale: u16) -> Self
Set the horizontal scale of the Figure
.
sourcepub fn add_labeled_edge_with(
self,
variant: EdgeVariant,
from: char,
to: char,
label: impl Into<String>
) -> Self
pub fn add_labeled_edge_with( self, variant: EdgeVariant, from: char, to: char, label: impl Into<String> ) -> Self
Add a labeled arrow / edge with a set of parameters to the Figure
.
sourcepub fn add_edge_with(self, variant: EdgeVariant, from: char, to: char) -> Self
pub fn add_edge_with(self, variant: EdgeVariant, from: char, to: char) -> Self
Add a unlabeled arrow / edge with a set of parameters to the Figure
.
sourcepub fn add_edge(self, edge: EdgeDefinition) -> Self
pub fn add_edge(self, edge: EdgeDefinition) -> Self
Add an arrow / edge to the Figure
.
sourcepub fn add_edges(self, edges: impl IntoIterator<Item = EdgeDefinition>) -> Self
pub fn add_edges(self, edges: impl IntoIterator<Item = EdgeDefinition>) -> Self
Add a set of arrows / edges to the Figure
.
sourcepub fn add_signal(self, signal: Signal) -> Self
pub fn add_signal(self, signal: Signal) -> Self
sourcepub fn add_signals(self, signals: impl IntoIterator<Item = Signal>) -> Self
pub fn add_signals(self, signals: impl IntoIterator<Item = Signal>) -> Self
sourcepub fn add_section(self, section: FigureSection) -> Self
pub fn add_section(self, section: FigureSection) -> Self
Add a FigureSection
to the Figure
.
sourcepub fn add_sections(
self,
sections: impl IntoIterator<Item = FigureSection>
) -> Self
pub fn add_sections( self, sections: impl IntoIterator<Item = FigureSection> ) -> Self
Add a set of FigureSection
s to the Figure
.
sourcepub fn add_group(self, group: FigureSectionGroup) -> Self
pub fn add_group(self, group: FigureSectionGroup) -> Self
Add a FigureSectionGroup
to the Figure
.
sourcepub fn add_groups(
self,
groups: impl IntoIterator<Item = FigureSectionGroup>
) -> Self
pub fn add_groups( self, groups: impl IntoIterator<Item = FigureSectionGroup> ) -> Self
Add a set of FigureSectionGroup
s to the Figure
.
sourcepub fn assemble_with_options(
&self,
options: PathAssembleOptions
) -> AssembledFigure<'_>
pub fn assemble_with_options( &self, options: PathAssembleOptions ) -> AssembledFigure<'_>
Form the signal paths and fetch information needed for rendering with a certain set of
PathAssembleOptions
.
Calling this with the default PathAssembleOptions
is equivalent to calling
Figure::assemble
. PathAssembleOptions
.
The assembly step is a necessary step to render the Digital Timing Diagram
. A more
detailed description can be found in the root level documentation.
sourcepub fn assemble(&self) -> AssembledFigure<'_>
pub fn assemble(&self) -> AssembledFigure<'_>
Form the signal paths and fetch information needed for rendering.
This is equivalent to calling Figure::assemble_with_options
with the default
PathAssembleOptions
.
The assembly step is a necessary step to render the Digital Timing Diagram
. A more
detailed description can be found in the root level documentation.