Struct wavedrom::Figure

source ·
pub struct Figure { /* private fields */ }
Expand description

An encapsulation of everything to form a Digital Timing Diagram

There are two ways to utilize Figure.

  1. Utilzing Figure::new and the builder pattern.
  2. 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:

Hello World!Bye World!

Implementations§

source§

impl Figure

source

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.

source

pub fn new() -> Self

Create a new empty Figure.

source

pub fn header_text(self, header_text: impl Into<String>) -> Self

Give a header text to the Figure.

source

pub fn footer_text(self, footer_text: impl Into<String>) -> Self

Give a footer text to the Figure.

source

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 everyth cycle.

source

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 everyth cycle.

source

pub fn horizontal_scale(self, hscale: u16) -> Self

Set the horizontal scale of the Figure.

source

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.

source

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.

source

pub fn add_edge(self, edge: EdgeDefinition) -> Self

Add an arrow / edge to the Figure.

source

pub fn add_edges(self, edges: impl IntoIterator<Item = EdgeDefinition>) -> Self

Add a set of arrows / edges to the Figure.

source

pub fn add_signal(self, signal: Signal) -> Self

Add a Signal line to the Figure.

source

pub fn add_signals(self, signals: impl IntoIterator<Item = Signal>) -> Self

Add a set of Signal lines to the Figure.

source

pub fn add_section(self, section: FigureSection) -> Self

Add a FigureSection to the Figure.

source

pub fn add_sections( self, sections: impl IntoIterator<Item = FigureSection> ) -> Self

Add a set of FigureSections to the Figure.

source

pub fn add_group(self, group: FigureSectionGroup) -> Self

Add a FigureSectionGroup to the Figure.

source

pub fn add_groups( self, groups: impl IntoIterator<Item = FigureSectionGroup> ) -> Self

Add a set of FigureSectionGroups to the Figure.

source

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.

source

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.

source§

impl Figure

source

pub fn from_json(s: &str) -> Result<Self, Error>

Available on crate features serde and serde_json only.
source

pub fn from_json5(s: &str) -> Result<Self, Error>

Available on crate features serde and json5 only.

Trait Implementations§

source§

impl Clone for Figure

source§

fn clone(&self) -> Figure

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Figure

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Figure

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<WaveJson> for Figure

Available on crate feature serde only.
source§

fn from(value: WaveJson) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.