1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum EncodingError {
6 #[error("IO error")]
7 IOError(#[from] io::Error),
8}
9
10pub type EncodingResult<T> = Result<T, EncodingError>;
11
12#[derive(Error, Debug)]
13pub enum ParserError {
14 #[error("IO error")]
15 IOError(#[from] io::Error),
16 #[error("field (tag = {0}) is missing from FIX dictionary")]
17 InvalidField(u32),
18 #[error("group (tag = {0}) is missing from FIX dictionary")]
19 InvalidGroup(u32),
20 #[error(
21 "field (tag = {tag}) is not in a valid position within the group (group tag = {group_tag})"
22 )]
23 InvalidGroupFieldOrder { tag: u32, group_tag: u32 },
24 #[error("component (name = {0}) is missing from FIX dictionary")]
25 InvalidComponent(String),
26 #[error("MsgType {0} is not a valid message type")]
27 InvalidMsgType(String),
28 #[error("malformed message: {0}")]
29 Malformed(String),
30}
31
32pub type ParserResult<T> = Result<T, ParserError>;
33
34#[derive(Error, Debug)]
35#[allow(clippy::enum_variant_names)]
36pub(crate) enum MessageIntegrityError {
37 #[error("Invalid BeginString")]
38 InvalidBeginString,
39 #[error("Invalid BodyLength")]
40 InvalidBodyLength,
41 #[error("Invalid MsgType")]
42 InvalidMsgType,
43 #[error("Invalid CheckSum")]
44 InvalidCheckSum,
45}