|  |  |  | @ -4,6 +4,8 @@ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | mod commands; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | use std::io::{BufRead, Write}; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | #[derive(Debug)] | 
			
		
	
		
			
				
					|  |  |  |  | pub struct Engine<'a, R, W> { | 
			
		
	
	
		
			
				
					|  |  |  | @ -31,11 +33,16 @@ 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, R, W> Engine<'a, R, W> { | 
			
		
	
		
			
				
					|  |  |  |  | impl<'a, R, W> Engine<'a, R, W> | 
			
		
	
		
			
				
					|  |  |  |  | where | 
			
		
	
		
			
				
					|  |  |  |  |   R: BufRead, | 
			
		
	
		
			
				
					|  |  |  |  |   W: Write, | 
			
		
	
		
			
				
					|  |  |  |  | { | 
			
		
	
		
			
				
					|  |  |  |  |   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.
 | 
			
		
	
		
			
				
					|  |  |  |  |     //       Engine options are all optional and appeared to be fixed by the UCI standard.
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     Engine { | 
			
		
	
		
			
				
					|  |  |  |  |       name: name, | 
			
		
	
	
		
			
				
					|  |  |  | @ -47,8 +54,8 @@ impl<'a, R, W> Engine<'a, R, W> { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   /// Sends identification messages to the writer for the GUI to pick up
 | 
			
		
	
		
			
				
					|  |  |  |  |   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); | 
			
		
	
		
			
				
					|  |  |  |  |     let name_id: String = format!("{} {} {}\n", commands::ID, commands::NAME, self.name); | 
			
		
	
		
			
				
					|  |  |  |  |     let author_id: String = format!("{} {} {}\n", commands::ID, commands::AUTHOR, self.author); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     // For these two writes we can panic - there's no possibility of recovery if the engine fails at this stage
 | 
			
		
	
		
			
				
					|  |  |  |  |     write!(&mut self.writer, "{}", name_id).expect("failed to send name identification to writer"); | 
			
		
	
	
		
			
				
					|  |  |  | 
 |