refix-fix44 0.12.0

Typed FIX 4.4 protocol messages for the ReFIX engine
Documentation
// @generated by refix codegen from FIX44.xml. Do not edit.
#![cfg_attr(rustfmt, rustfmt::skip)]

use refix_message::{Decimal, InvalidValue, LazyKnownTags, Tag};

use super::super::enums::{PegLimitType, PegMoveType, PegOffsetType, PegRoundDirection, PegScope};

/// The fields of the `PegInstructions` component.
#[derive(Clone, Copy)]
pub struct PegInstructions<'a>(pub(in super::super) refix_message::Scope<'a>);

impl<'a> PegInstructions<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(211), Tag(835), Tag(836), Tag(837), Tag(838), Tag(840)],
            &[],
        );
        &TAGS
    }

    pub fn raw(&self) -> refix_message::Scope<'a> {
        self.0
    }

    /// The `PegOffsetValue` (211) field.
    #[doc(alias = "PegOffsetValue")]
    pub fn peg_offset_value(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(211))
    }

    /// The `PegMoveType` (835) field.
    #[doc(alias = "PegMoveType")]
    pub fn peg_move_type(&self) -> Result<Option<PegMoveType>, InvalidValue> {
        Ok(self.0.get_int(Tag(835))?.map(PegMoveType::from_value))
    }

    /// The `PegOffsetType` (836) field.
    #[doc(alias = "PegOffsetType")]
    pub fn peg_offset_type(&self) -> Result<Option<PegOffsetType>, InvalidValue> {
        Ok(self.0.get_int(Tag(836))?.map(PegOffsetType::from_value))
    }

    /// The `PegLimitType` (837) field.
    #[doc(alias = "PegLimitType")]
    pub fn peg_limit_type(&self) -> Result<Option<PegLimitType>, InvalidValue> {
        Ok(self.0.get_int(Tag(837))?.map(PegLimitType::from_value))
    }

    /// The `PegRoundDirection` (838) field.
    #[doc(alias = "PegRoundDirection")]
    pub fn peg_round_direction(&self) -> Result<Option<PegRoundDirection>, InvalidValue> {
        Ok(self.0.get_int(Tag(838))?.map(PegRoundDirection::from_value))
    }

    /// The `PegScope` (840) field.
    #[doc(alias = "PegScope")]
    pub fn peg_scope(&self) -> Result<Option<PegScope>, InvalidValue> {
        Ok(self.0.get_int(Tag(840))?.map(PegScope::from_value))
    }
}

impl std::fmt::Debug for PegInstructions<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "PegInstructions({})", self.0.display_known(&Self::known_tags().get()))
    }
}