use error::LaseError;
use etherdream::protocol::Point;
use etherdream;
use point::PipelinePoint;
use point::SimplePoint;
use std::net::IpAddr;
pub enum Dac {
Etherdream {
dac: etherdream::dac::Dac
},
}
impl Dac {
pub fn etherdream(ip_addr: IpAddr) -> Dac {
Dac::Etherdream { dac: etherdream::dac::Dac::new(ip_addr) }
}
pub fn get_ip_address(&self) -> Option<&IpAddr> {
match self {
&Dac::Etherdream { ref dac } => Some(&dac.get_ip_address()),
}
}
pub fn play_function<F>(&mut self, make_points: F)
-> Result<(), LaseError> where F: FnMut(u16) -> Vec<Point> {
match self {
&mut Dac::Etherdream { ref mut dac } => {
dac.play_function(make_points).map_err(|e| e.into())
},
}
}
pub fn stream_pipeline_points<F>(&mut self, make_points: F)
-> Result<(), LaseError> where F: FnMut(u16) -> Vec<PipelinePoint> {
match self {
&mut Dac::Etherdream { ref mut dac } => {
dac.stream_pipeline_points(make_points).map_err(|e| e.into())
},
}
}
pub fn stream_simple_points<F>(&mut self, make_points: F)
-> Result<(), LaseError> where F: FnMut(u16) -> Vec<SimplePoint> {
match self {
&mut Dac::Etherdream { ref mut dac } => {
dac.stream_simple_points(make_points).map_err(|e| e.into())
},
}
}
}