1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use super::gtp_type::*;
use std::io;
pub trait WriteGTP {
fn write_gtp(&self, &mut impl io::Write) -> io::Result<()>;
}
pub struct Command {
id: Option<Int>,
command_name: String,
arguments: List,
}
impl WriteGTP for Command {
fn write_gtp(&self, f: &mut impl io::Write) -> io::Result<()> {
if let Some(id) = &self.id {
id.write_gtp(f)?;
f.write_all(b" ")?;
};
self.command_name.write_gtp(f)?;
if !self.arguments.is_empty() {
f.write_all(b" ")?;
self.arguments.write_gtp(f)?;
};
Ok(())
}
}
pub struct Response {
id: Option<Int>,
success: bool,
content: MultilineList,
}
impl WriteGTP for Response {
fn write_gtp(&self, f: &mut impl io::Write) -> io::Result<()> {
unimplemented!()
}
}