hotfix-message 0.4.0

FIX messages for HotFIX.
Documentation
use hotfix_dictionary::TagU32;
use std::collections::HashSet;
use std::io;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum EncodingError {
    #[error("IO error")]
    IOError(#[from] io::Error),
}

pub type EncodingResult<T> = Result<T, EncodingError>;

#[derive(Error, Debug)]
pub enum ParserError {
    #[error("IO error")]
    IOError(#[from] io::Error),
    #[error("field (tag = {0}) is missing from FIX dictionary")]
    InvalidField(u32),
    #[error("group (tag = {0}) is missing from FIX dictionary")]
    InvalidGroup(u32),
    #[error(
        "field (tag = {tag}) is not in a valid position within the group (group tag = {group_tag})"
    )]
    InvalidGroupFieldOrder { tag: u32, group_tag: u32 },
    #[error("component (name = {0}) is missing from FIX dictionary")]
    InvalidComponent(String),
    #[error("MsgType {0} is not a valid message type")]
    InvalidMsgType(String),
    #[error(
        "required field (tag = {tag}) is missing{}",
        match group_tag { Some(g) => format!(" from repeating group (group tag = {g})"), None => String::new() }
    )]
    RequiredFieldMissing { tag: u32, group_tag: Option<u32> },
    #[error("malformed message: {0}")]
    Malformed(String),
}

pub type ParserResult<T> = Result<T, ParserError>;

#[derive(Error, Debug)]
#[allow(clippy::enum_variant_names)]
pub(crate) enum MessageIntegrityError {
    #[error("Invalid BeginString")]
    InvalidBeginString,
    #[error("Invalid BodyLength")]
    InvalidBodyLength,
    #[error("Invalid MsgType")]
    InvalidMsgType,
    #[error("Invalid CheckSum")]
    InvalidCheckSum,
}

#[derive(Error, Debug)]
pub enum SetGroupsError {
    #[error("Supplied empty vector of groups")]
    EmptyGroups,
    #[error("Supplied groups contain multiple start tags")]
    MultipleStartTagsAndDelimiters(HashSet<(TagU32, TagU32)>),
}