[−][src]Module preexplorer::traits
Traits for easy use or self implmentation.
Implementing
You should proceed in the following order.
Configurable
Include Configuration as a new field config
of your struct.
This allows to handle all options. Then, include the following code.
struct MyStruct{config: preexplorer::Configuration}; impl preexplorer::Configurable for MyStruct { fn configuration_mut(&mut self) -> &mut preexplorer::Configuration { &mut self.config } fn configuration(&self) -> &preexplorer::Configuration { &self.config } }
Saveable
Extract the data to plot from your struct in the form of a String. Different from serializing your struct, you only want the data.
Examples
After implementing Configurable.
struct MyStruct { content: f64, config: preexplorer::Configuration, }; impl preexplorer::Saveable for MyStruct { fn plotable_data(&self) -> String { let mut plotable_data = String::new(); plotable_data.push_str(&format!("{}", self.content)); plotable_data } }
Plotable
Write your own plot script to be executed in gnuplot. You can base this script by helper functions from the Configurable trait.
Examples
After implementing Configurable and Saveable.
struct MyStruct { content: f64, config: preexplorer::Configuration, }; impl preexplorer::Plotable for MyStruct { fn plot_script(&self) -> String { // Start with a basis that takes into account configuration options. let mut gnuplot_script = self.opening_plot_script(); // Retrieve your own options or simply personalize the plot command. let dashtype = match self.dashtype() { Some(dashtype) => dashtype, None => 1, }; // Include the main plot command. gnuplot_script += &format!( "plot {:?} with {} dashtype {} \n", self.data_path(), self.style(), dashtype, ); // End with other configuration options. gnuplot_script += &self.ending_plot_script(); gnuplot_script } }
Traits
Configurable | Allows basic saving and plotting configuration. |
Plotable | Allows quick plotting. |
Preexplore | Quickly transform interators in |
PreexploreProcess | Quickly transform tuples of interators in |
Saveable | Allows quick saving. |