irc-command-micro
Early implementation of a parser for irc messages
Parse a simple NAMES command, CR and LF is optional
use Message;
let message_bytes = vec!;
let message = parse.unwrap;
println!;
//Message { source: Some("Anon"), command: NAMES, params: [] }
Parse a NICK command that contains a single parameter
let message_bytes = vec!;
let message = parse.unwrap;
println!;
// Message { source: Some("Anon"), command: NICK, params: ["Dave"] }
Here is the same NICK command but without the provided parameter
let message_bytes = vec!;
let message = parse;
println!;
// Err(MessageError { detail: NotEnoughParams })
Now the client has sent a NICK command but not capitalised correctly (Nick)
let message_bytes = vec!;
let message = parse;
println!;
// Err(MessageError { detail: InvalidCommand })
Whitespace will also be stripped from the start and end
let message_bytes = vec!;
let message = parse;
println!;
// Message { source: Some("Anon"), command: NICK, params: ["Anon2"] }
You can also construct a Message
manually
let message = new
A message object can then be returned to a value to be transmitted, CR and LF is added making exact return value valid
let tcp_data: = message.serialize
// [58, 65, 110, 111, 110, 32, 78, 65, 77, 69, 83, 13, 10]