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
54
55
56
57
58
59
60
61
62
63
64
65
66
use std::num::ParseFloatError;
use std::num::ParseIntError;

use chrono::naive::NaiveDateTime;
use chrono::{DateTime, Duration, Utc};
use failure::Fail;
use tsproto::packets::{Direction, PacketType};

use crate::errors::Error;
use crate::*;

#[derive(Fail, Debug)]
pub enum ParseError {
	#[fail(display = "Parameter {} not found in {}", arg, name)]
	ParameterNotFound {
		arg: &'static str,
		name: &'static str,
	},
	#[fail(display = "Command {} is unknown", _0)]
	UnknownCommand(String),
	/// Gets thrown when parsing a specific command with the wrong input.
	#[fail(display = "Command {} is wrong", _0)]
	WrongCommand(String),
	#[fail(display = "Wrong newprotocol flag ({})", _0)]
	WrongNewprotocol(bool),
	#[fail(display = "Wrong packet type {:?}", _0)]
	WrongPacketType(PacketType),
	#[fail(display = "Wrong direction {:?}", _0)]
	WrongDirection(Direction),
	#[fail(
		display = "Cannot parse \"{}\" as int for parameter {} ({})",
		value, arg, error
	)]
	ParseInt {
		arg: &'static str,
		value: String,
		#[cause]
		error: ParseIntError,
	},
	#[fail(
		display = "Cannot parse \"{}\" as float for parameter {} ({})",
		value, arg, error
	)]
	ParseFloat {
		arg: &'static str,
		value: String,
		#[cause]
		error: ParseFloatError,
	},
	#[fail(
		display = "Cannot parse \"{}\" as bool for parameter {}",
		value, arg
	)]
	ParseBool { arg: &'static str, value: String },
	#[fail(display = "Invalid value \"{}\" for parameter {}", value, arg)]
	InvalidValue { arg: &'static str, value: String },
}

pub mod s2c {
	use super::*;
	include!(concat!(env!("OUT_DIR"), "/s2c_messages.rs"));
}
pub mod c2s {
	use super::*;
	include!(concat!(env!("OUT_DIR"), "/c2s_messages.rs"));
}