use super::string::IrcString;
#[derive(Clone, PartialEq, Eq)]
pub enum IrcCommand {
Textual(IrcString),
Numeric(u16) }
#[derive(Clone, PartialEq, Eq)]
pub struct IrcLine {
command: IrcCommand,
arguments: Vec<IrcString>,
}
#[derive(Clone, PartialEq, Eq)]
pub struct IrcLineBuilder {
command: Option<IrcCommand>,
arguments: Vec<IrcString>,
}
impl IrcLineBuilder {
pub fn new() -> IrcLineBuilder {
IrcLineBuilder {
command: None,
arguments: Vec::new(),
}
}
pub fn get_command(&self) -> &Option<IrcCommand> {
&self.command
}
pub fn set_command(&mut self, command: Option<IrcCommand>) {
self.command = command;
}
pub fn build(self) -> Result<IrcLine, Self> {
match self {
IrcLineBuilder {
command: Some(command),
arguments,
} => {
Ok(IrcLine {
command: command,
arguments: arguments,
})
}
_ => Err(self)
}
}
}