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, Instances, InvalidValue, KnownTags, LazyKnownTags, Tag};

use super::super::enums::DeliveryForm;
use super::AttrbGrp;

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

impl<'a> InstrumentExtension<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(668), Tag(869), Tag(870)],
            &[AttrbGrp::known_tags()],
        );
        &TAGS
    }

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

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

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

    /// The instances of the `NoInstrAttrib` (870) group.
    #[doc(alias = "NoInstrAttrib")]
    pub fn instr_attrib(&self) -> Result<Instances<'a, AttrbGrp<'a>>, InvalidValue> {
        self.0.get_group(&AttrbGrp::TABLE, &self.1).map(Instances::from)
    }
}

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