#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{
Decimal, Instances, InvalidValue, LazyKnownTags, MultipleValues, RawMessage, Tag, UtcTimestamp,
};
use super::super::components::{
Header, InstrmtLegGrp, Instrument, InstrumentExtension, Trailer, UndInstrmtGrp,
};
use super::super::enums::{
Adjustment, CorporateAction, FinancialStatus, HaltReasonChar, SecurityTradingStatus,
};
pub struct SecurityStatus(RawMessage);
impl SecurityStatus {
pub const MSG_TYPE: &[u8] = b"f";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(324), Tag(711), Tag(555), Tag(15), Tag(336), Tag(625), Tag(325), Tag(326),
Tag(291), Tag(292), Tag(327), Tag(328), Tag(329), Tag(330), Tag(331), Tag(332),
Tag(333), Tag(31), Tag(60), Tag(334), Tag(58), Tag(354), Tag(355),
],
&[
Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
InstrumentExtension::known_tags(), UndInstrmtGrp::known_tags(),
InstrmtLegGrp::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())
}
#[doc(alias = "SecurityStatusReqID")]
pub fn security_status_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(324))
}
pub fn instrument(&self) -> Instrument<'_> {
Instrument(self.0.scope(), Self::known_tags().get())
}
pub fn instrument_extension(&self) -> InstrumentExtension<'_> {
InstrumentExtension(self.0.scope(), Self::known_tags().get())
}
#[doc(alias = "NoUnderlyings")]
pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, InvalidValue> {
self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoLegs")]
pub fn legs(&self) -> Result<Instances<'_, InstrmtLegGrp<'_>>, InvalidValue> {
self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "Currency")]
pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(15))
}
#[doc(alias = "TradingSessionID")]
pub fn trading_session_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(336))
}
#[doc(alias = "TradingSessionSubID")]
pub fn trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(625))
}
#[doc(alias = "UnsolicitedIndicator")]
pub fn unsolicited_indicator(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(325))
}
#[doc(alias = "SecurityTradingStatus")]
pub fn security_trading_status(&self) -> Result<Option<SecurityTradingStatus>, InvalidValue> {
Ok(self.0.get_int(Tag(326))?.map(SecurityTradingStatus::from_value))
}
#[doc(alias = "FinancialStatus")]
pub fn financial_status(&self) -> Result<Option<MultipleValues<'_, FinancialStatus<'_>>>, InvalidValue> {
self.0.get_multiple_values(Tag(291))
}
#[doc(alias = "CorporateAction")]
pub fn corporate_action(&self) -> Result<Option<MultipleValues<'_, CorporateAction<'_>>>, InvalidValue> {
self.0.get_multiple_values(Tag(292))
}
#[doc(alias = "HaltReasonChar")]
pub fn halt_reason_char(&self) -> Result<Option<HaltReasonChar<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(327))?.map(HaltReasonChar::from_value))
}
#[doc(alias = "InViewOfCommon")]
pub fn in_view_of_common(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(328))
}
#[doc(alias = "DueToRelated")]
pub fn due_to_related(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(329))
}
#[doc(alias = "BuyVolume")]
pub fn buy_volume(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(330))
}
#[doc(alias = "SellVolume")]
pub fn sell_volume(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(331))
}
#[doc(alias = "HighPx")]
pub fn high_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(332))
}
#[doc(alias = "LowPx")]
pub fn low_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(333))
}
#[doc(alias = "LastPx")]
pub fn last_px(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(31))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[doc(alias = "Adjustment")]
pub fn adjustment(&self) -> Result<Option<Adjustment>, InvalidValue> {
Ok(self.0.get_int(Tag(334))?.map(Adjustment::from_value))
}
#[doc(alias = "Text")]
pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(58))
}
#[doc(alias = "EncodedTextLen")]
pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(354))
}
#[doc(alias = "EncodedText")]
pub fn encoded_text(&self) -> Option<&[u8]> {
self.0.get(Tag(355))
}
}
impl std::fmt::Debug for SecurityStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SecurityStatus({})", self.0)
}
}
impl std::fmt::Display for SecurityStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}