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::{
    Date, Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp,
};

use super::super::components::{
    Header, InstrmtLegGrp, Instrument, Parties, PositionQty, Trailer, TrdgSesGrp, UndInstrmtGrp,
};
use super::super::enums::{
    AccountType, AcctIDSource, AdjustmentType, PosMaintAction, PosTransType, SettlSessID,
};

/// The `PositionMaintenanceRequest` (35=AL) message.
pub struct PositionMaintenanceRequest(RawMessage);

impl PositionMaintenanceRequest {
    pub const MSG_TYPE: &[u8] = b"AL";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(710), Tag(709), Tag(712), Tag(713), Tag(714), Tag(715), Tag(716), Tag(717),
                Tag(453), Tag(1), Tag(660), Tag(581), Tag(15), Tag(555), Tag(711), Tag(386),
                Tag(60), Tag(702), Tag(718), Tag(719), Tag(720), Tag(834), Tag(58), Tag(354),
                Tag(355),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(), Parties::known_tags(),
                Instrument::known_tags(), InstrmtLegGrp::known_tags(), UndInstrmtGrp::known_tags(),
                TrdgSesGrp::known_tags(), PositionQty::known_tags(),
            ],
        );
        &TAGS
    }

    pub fn from_raw(raw: RawMessage) -> Self {
        Self(raw)
    }

    pub fn raw(&self) -> &RawMessage {
        &self.0
    }

    pub fn header(&self) -> Header<'_> {
        Header(self.0.scope(), Self::known_tags().get())
    }

    pub fn trailer(&self) -> Trailer<'_> {
        Trailer(self.0.scope())
    }

    /// The `PosReqID` (710) field.
    #[doc(alias = "PosReqID")]
    pub fn pos_req_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(710))
    }

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

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

    /// The `OrigPosReqRefID` (713) field.
    #[doc(alias = "OrigPosReqRefID")]
    pub fn orig_pos_req_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(713))
    }

    /// The `PosMaintRptRefID` (714) field.
    #[doc(alias = "PosMaintRptRefID")]
    pub fn pos_maint_rpt_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(714))
    }

    /// The `ClearingBusinessDate` (715) field.
    #[doc(alias = "ClearingBusinessDate")]
    pub fn clearing_business_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(715))
    }

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

    /// The `SettlSessSubID` (717) field.
    #[doc(alias = "SettlSessSubID")]
    pub fn settl_sess_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(717))
    }

    /// The instances of the `NoPartyIDs` (453) group.
    #[doc(alias = "NoPartyIDs")]
    pub fn party_ids(&self) -> Result<Instances<'_, Parties<'_>>, InvalidValue> {
        self.0.get_group(&Parties::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

    /// The `Account` (1) field.
    #[doc(alias = "Account")]
    pub fn account(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(1))
    }

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

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

    /// The `Instrument` component.
    pub fn instrument(&self) -> Instrument<'_> {
        Instrument(self.0.scope(), Self::known_tags().get())
    }

    /// The `Currency` (15) field.
    #[doc(alias = "Currency")]
    pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(15))
    }

    /// The instances of the `NoLegs` (555) group.
    #[doc(alias = "NoLegs")]
    pub fn legs(&self) -> Result<Instances<'_, InstrmtLegGrp<'_>>, InvalidValue> {
        self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

    /// The instances of the `NoUnderlyings` (711) group.
    #[doc(alias = "NoUnderlyings")]
    pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
        self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

    /// The instances of the `NoTradingSessions` (386) group.
    #[doc(alias = "NoTradingSessions")]
    pub fn trading_sessions(&self) -> Result<Instances<'_, TrdgSesGrp<'_>>, InvalidValue> {
        self.0.get_group(&TrdgSesGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

    /// The `TransactTime` (60) field.
    #[doc(alias = "TransactTime")]
    pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
        self.0.get_utc_timestamp(Tag(60))
    }

    /// The instances of the `NoPositions` (702) group.
    #[doc(alias = "NoPositions")]
    pub fn positions(&self) -> Result<Instances<'_, PositionQty<'_>>, InvalidValue> {
        self.0.get_group(&PositionQty::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

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

    /// The `ContraryInstructionIndicator` (719) field.
    #[doc(alias = "ContraryInstructionIndicator")]
    pub fn contrary_instruction_indicator(&self) -> Result<Option<bool>, InvalidValue> {
        self.0.get_bool(Tag(719))
    }

    /// The `PriorSpreadIndicator` (720) field.
    #[doc(alias = "PriorSpreadIndicator")]
    pub fn prior_spread_indicator(&self) -> Result<Option<bool>, InvalidValue> {
        self.0.get_bool(Tag(720))
    }

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

    /// The `Text` (58) field.
    #[doc(alias = "Text")]
    pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(58))
    }

    /// The `EncodedTextLen` (354) field.
    #[doc(alias = "EncodedTextLen")]
    pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
        self.0.get_int(Tag(354))
    }

    /// The `EncodedText` (355) field.
    #[doc(alias = "EncodedText")]
    pub fn encoded_text(&self) -> Option<&[u8]> {
        self.0.get(Tag(355))
    }
}

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

impl std::fmt::Display for PositionMaintenanceRequest {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(&self.0, f)
    }
}