message_format/
parse_message.rs

1// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4// option. This file may not be copied, modified, or distributed
5// except according to those terms.
6
7use std::error::Error;
8use std::fmt;
9
10use super::Message;
11
12/// An error resulting from `parse_message`.
13#[derive(Clone,Debug)]
14pub enum ParseError {
15    /// The message could not be parsed.
16    NotImplemented,
17}
18
19impl Error for ParseError {
20    fn description(&self) -> &str {
21        match *self {
22            ParseError::NotImplemented => "Not implemented.",
23        }
24    }
25}
26
27impl fmt::Display for ParseError {
28    fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
29        self.description().fmt(f)
30    }
31}
32
33/// Parse some text and hopefully return a `Message`.
34pub fn parse_message(_message: &str) -> Result<Message, ParseError> {
35    Err(ParseError::NotImplemented)
36}