Struct rain::Graph
[−]
[src]
pub struct Graph<V> { /* fields omitted */ }The graph drawing structure
Methods
impl<V> Graph<V> where V: Clone + Default + Ord + PartialEq + Debug,
f64: From<V>[src]
f64: From<V>
fn new() -> Self
fn with_prefix_length(length: usize) -> Self
Create a new Graph for drawing with a custom length of the identifier (prefix)
Example
use rain::Graph; let _ :Graph<u8> = Graph::with_prefix_length(25);
fn set_log_level(self, level: LogLevel) -> Self
Set the global log level for reporting
fn add<T>(&mut self, identifier: T, value: V) -> RainResult<T> where T: Display
Add a data value to the graph by some identifier which can be displayed somehow.
Example
use rain::Graph; let mut graph = Graph::new(); let line = graph.add("Line 1", 0).unwrap(); assert_eq!(line, "Line 1");
fn remove<T>(&mut self, identifier: T) -> RainResult<T> where T: Display
Remove a line from the graph
Example
use rain::Graph; let mut graph = Graph::new(); let line = graph.add("Line 1", 0).unwrap(); let removed_line = graph.remove(line).unwrap(); assert_eq!(removed_line, "Line 1");
fn print(&mut self) -> RainResult<()>
Prints the graph
Example
use rain::Graph; let mut graph = Graph::new(); assert!(graph.add("Line 1", 0).is_ok()); assert!(graph.add("Line 2", 0).is_ok()); graph.print();
fn print_if_new_data(&mut self) -> RainResult<bool>
Print only if new data is available. Returns an indicator if somethings was printed or not.
Example
use rain::Graph; let mut graph = Graph::new(); assert!(graph.add("Line 1", 0).is_ok()); assert!(graph.add("Line 2", 0).is_ok()); graph.print_if_new_data(); graph.print_if_new_data();