Visualizer

Struct Visualizer 

Source
pub struct Visualizer { /* private fields */ }
Expand description

OxiDD-vis-compatible decision diagram exporter that serves decision diagram dumps on localhost via HTTP

OxiDD-vis is a webapp that runs locally in your browser. You can directly send decision diagrams to it via an HTTP connection. Here, the Visualizer acts as a small HTTP server that accepts connections once you call Visualizer::serve(). The webapp repeatedly polls on the configured port to directly display the decision diagrams then.

Implementations§

Source§

impl Visualizer

Source

pub fn new() -> Self

Create a new visualizer

Source

pub fn port(self, port: u16) -> Self

Customize the port on which to serve the visualization data

The default port is 4000.

Returns self.

Source

pub fn add<'id, FR: Deref>( self, diagram_name: &str, manager: &<FR::Target as Function>::Manager<'id>, functions: impl IntoIterator<Item = FR>, ) -> Self

Add a decision diagram for visualization

diagram_name can be used as an identifier in case you add multiple diagrams. functions is an iterator over Functions.

The visualization includes all nodes reachable from the root nodes referenced by functions. If you wish to name the functions, use Self::add_with_names().

Returns self to allow chaining.

§Example
Visualizer::new()
    .add("my_diagram", manager, [f0, f1])
    .serve()
    .expect("failed to serve diagram due to I/O error")
Source

pub fn add_with_names<'id, FR: Deref, D: Display>( self, diagram_name: &str, manager: &<FR::Target as Function>::Manager<'id>, functions: impl IntoIterator<Item = (FR, D)>, ) -> Self

Add a decision diagram for visualization

diagram_name can be used as an identifier in case you add multiple diagrams. functions is an iterator over pairs of a Function and a name.

The visualization includes all nodes reachable from the root nodes referenced by functions.

Returns self to allow chaining.

§Example
Visualizer::new()
    .add_with_names("my_diagram", manager, [(phi, "ϕ"), (res, "result")])
    .serve()
    .expect("failed to serve diagram due to I/O error")
Source

pub fn clear(&mut self)

Remove all previously added decision diagrams

Source

pub fn serve(&mut self) -> Result<()>

Serve the provided decision diagram for visualization

Blocks until the visualization has been fetched by OxiDD-vis (or another compatible tool).

On success, all previously added decision diagrams are removed from the internal buffer. On error, the internal buffer is left as-is.

Source

pub fn serve_nonblocking(&mut self) -> Result<VisualizationListener<'_>>

Non-blocking version of Self::serve()

Unlike Self::serve(), this method sets the TcpListener into non-blocking mode, allowing to run different tasks while waiting for a connection by OxiDD-vis (or another compatible tool).

Note that you need to call poll() repeatedly on the returned VisualizationListener to accept a TCP connection.

Trait Implementations§

Source§

impl Default for Visualizer

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.