|
|
|
@ -4,7 +4,6 @@
|
|
|
|
|
|
|
|
|
|
mod commands; |
|
|
|
|
|
|
|
|
|
use std::fmt; |
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
|
pub struct Engine<'a, R, W> { |
|
|
|
@ -32,8 +31,8 @@ pub struct Engine<'a, R, W> {
|
|
|
|
|
/// Additionally this code should have a parser. You call it with the reader supplied and it waits for a command
|
|
|
|
|
/// and parses it into a tuple of some kind for the user.
|
|
|
|
|
|
|
|
|
|
impl<'a> Engine<'a, R, W> { |
|
|
|
|
pub fn new(name: &'a str, author: &'a str, reader: R, writer: W) -> Engine<'a> { |
|
|
|
|
impl<'a, R, W> Engine<'a, R, W> { |
|
|
|
|
pub fn new(name: &'a str, author: &'a str, reader: R, writer: W) -> Engine<'a, R, W> { |
|
|
|
|
|
|
|
|
|
// TODO: This should also take an EngineOptions thing that indicates which options are supported
|
|
|
|
|
// so that when called it can send them easily.
|
|
|
|
@ -41,14 +40,12 @@ impl<'a> Engine<'a, R, W> {
|
|
|
|
|
Engine { |
|
|
|
|
name: name, |
|
|
|
|
author: author, |
|
|
|
|
reader: R, |
|
|
|
|
writer: W, |
|
|
|
|
reader: reader, |
|
|
|
|
writer: writer, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Sends identification messages to the writer for the GUI to pick up
|
|
|
|
|
/// TODO: Write tests for this. Reference:
|
|
|
|
|
/// https://stackoverflow.com/questions/28370126/how-can-i-test-stdin-and-stdout
|
|
|
|
|
pub fn identify(&mut self) { |
|
|
|
|
let name_id: String = format!("{} {} {}", commands::ID, commands::NAME, self.name); |
|
|
|
|
let author_id: String = format!("{} {} {}", commands::ID, commands::AUTHOR, self.author); |
|
|
|
|