#![deny(warnings)]
#![deny(missing_docs)]
#[macro_use]
extern crate derive_builder;
#[macro_use]
extern crate log;
use std::fmt::Debug;
mod graph;
pub use graph::{Config, ConfigBuilder, Graph, PointStyle, View, ViewMode};
mod graph_with_controls;
pub use graph_with_controls::GraphWithControls;
mod null_data_source;
pub use null_data_source::NullDataSource;
pub mod observable_value;
mod signal;
pub use signal::Signal;
mod store;
use store::Store;
mod test_data_generator;
pub use test_data_generator::TestDataGenerator;
#[derive(Debug)]
pub enum Error {
String(String),
}
pub type Result<T> = std::result::Result<T, Error>;
pub type Time = u32;
pub type Value = u16;
#[derive(Debug, Clone)]
pub struct Point {
pub t: Time,
pub vs: Vec<Value>,
}
impl Point {
pub fn t(&self) -> Time {
self.t
}
pub fn vals(&self) -> &[Value] {
&self.vs
}
}
#[derive(Clone, Copy)]
pub struct Color(pub u8, pub u8, pub u8);
impl Color {
pub fn from_rgb(r: u8, g: u8, b: u8) -> Color {
Color(r, g, b)
}
pub fn r(&self) -> u8 {
self.0
}
pub fn g(&self) -> u8 {
self.1
}
pub fn b(&self) -> u8 {
self.2
}
}
#[cfg(test)]
mod color_tests {
use super::Color;
#[test]
fn values() {
let c = Color::from_rgb(10, 20, 30);
assert_eq!(c.r(), 10);
assert_eq!(c.g(), 20);
assert_eq!(c.b(), 30);
}
}
pub trait DataSource: Debug + Send {
fn get_data(&mut self) -> Result<Vec<Point>>;
fn get_num_values(&self) -> Result<usize>;
fn get_colors(&self) -> Result<Vec<Color>> {
Ok(vec![Color(255u8, 0u8, 0u8),
Color(0u8, 255u8, 0u8),
Color(0u8, 0u8, 255u8)
])
}
}