gnuplot_wrapper/process/
gnuplot_live_process.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::{io::Write, process::Child};

use crate::process::gnuplot_process::GnuplotProcess;

pub struct GnuplotLiveProcess {
    child: Child
}

impl GnuplotProcess for GnuplotLiveProcess {
    fn new(child: Child) -> Self {
        return GnuplotLiveProcess { child: child };
    }

    fn wait(&mut self) {
        self.child.wait().unwrap();
    }
}

impl GnuplotLiveProcess {
    pub fn write(&mut self, command: &str) {
        self.child.stdin.as_mut().unwrap().write_fmt(format_args!("{}\n", command)).unwrap();
    }
}