[][src]Function vampirc_uci::parser::parse_one

pub fn parse_one(s: &str) -> UciMessage

Parses and returns a single message, with or without a terminating newline. Usually used in a loop that reads a single line from an input stream, such as the stdin. Note that if the message is unrecognizable to the parser, a UciMessage::UnknownMessage variant is returned.

Only the first command in the s parameter will be returned, if there are more than one in that string.

/// # Examples

use std::io::{self, BufRead};
use vampirc_uci::{UciMessage, parse_one};

for line in io::stdin().lock().lines() {
        let msg: UciMessage = parse_one(&line.unwrap());
        println!("Received message: {}", msg);
    }