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::{
    DiscretionInst, DiscretionLimitType, DiscretionMoveType, DiscretionOffsetType,
    DiscretionRoundDirection, DiscretionScope,
};

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

impl<'a> DiscretionInstructions<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(388), Tag(389), Tag(841), Tag(842), Tag(843), Tag(844), Tag(846)],
            &[],
        );
        &TAGS
    }

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

    /// The `DiscretionInst` (388) field.
    #[doc(alias = "DiscretionInst")]
    pub fn discretion_inst(&self) -> Result<Option<DiscretionInst<'a>>, InvalidValue> {
        Ok(self.0.get_str(Tag(388))?.map(DiscretionInst::from_value))
    }

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

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

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

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

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

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

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