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::{CommType, FundRenewWaiv};

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

impl<'a> CommissionData<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(12), Tag(13), Tag(479), Tag(497)],
            &[],
        );
        &TAGS
    }

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

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

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

    /// The `CommCurrency` (479) field.
    #[doc(alias = "CommCurrency")]
    pub fn comm_currency(&self) -> Result<Option<&'a str>, InvalidValue> {
        self.0.get_str(Tag(479))
    }

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

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