#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Decimal, Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp};
use super::super::components::{
FinancingDetails, Header, IOIQualGrp, InstrmtLegIOIGrp, Instrument, OrderQtyData, RoutingGrp,
SpreadOrBenchmarkCurveData, Stipulations, Trailer, UndInstrmtGrp, YieldData,
};
use super::super::enums::{IOIQltyInd, IOIQty, IOITransType, PriceType, QtyType, Side};
pub struct IOI(RawMessage);
impl IOI {
pub const MSG_TYPE: &[u8] = b"6";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(23), Tag(28), Tag(26), Tag(711), Tag(54), Tag(854), Tag(27), Tag(15), Tag(232),
Tag(555), Tag(423), Tag(44), Tag(62), Tag(25), Tag(130), Tag(199), Tag(58),
Tag(354), Tag(355), Tag(60), Tag(149), Tag(215),
],
&[
Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
FinancingDetails::known_tags(), UndInstrmtGrp::known_tags(),
OrderQtyData::known_tags(), Stipulations::known_tags(),
InstrmtLegIOIGrp::known_tags(), IOIQualGrp::known_tags(), RoutingGrp::known_tags(),
SpreadOrBenchmarkCurveData::known_tags(), YieldData::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 = "IOIID")]
pub fn ioiid(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(23))
}
#[doc(alias = "IOITransType")]
pub fn ioi_trans_type(&self) -> Result<Option<IOITransType<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(28))?.map(IOITransType::from_value))
}
#[doc(alias = "IOIRefID")]
pub fn ioi_ref_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(26))
}
pub fn instrument(&self) -> Instrument<'_> {
Instrument(self.0.scope(), Self::known_tags().get())
}
pub fn financing_details(&self) -> FinancingDetails<'_> {
FinancingDetails(self.0.scope())
}
#[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 = "Side")]
pub fn side(&self) -> Result<Option<Side<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(54))?.map(Side::from_value))
}
#[doc(alias = "QtyType")]
pub fn qty_type(&self) -> Result<Option<QtyType>, InvalidValue> {
Ok(self.0.get_int(Tag(854))?.map(QtyType::from_value))
}
pub fn order_qty_data(&self) -> OrderQtyData<'_> {
OrderQtyData(self.0.scope())
}
#[doc(alias = "IOIQty")]
pub fn ioi_qty(&self) -> Result<Option<IOIQty<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(27))?.map(IOIQty::from_value))
}
#[doc(alias = "Currency")]
pub fn currency(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(15))
}
#[doc(alias = "NoStipulations")]
pub fn stipulations(&self) -> Result<Instances<'_, Stipulations<'_>>, InvalidValue> {
self.0.get_group(&Stipulations::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "NoLegs")]
pub fn legs(&self) -> Result<Instances<'_, InstrmtLegIOIGrp<'_>>, InvalidValue> {
self.0.get_group(&InstrmtLegIOIGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "PriceType")]
pub fn price_type(&self) -> Result<Option<PriceType>, InvalidValue> {
Ok(self.0.get_int(Tag(423))?.map(PriceType::from_value))
}
#[doc(alias = "Price")]
pub fn price(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(44))
}
#[doc(alias = "ValidUntilTime")]
pub fn valid_until_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(62))
}
#[doc(alias = "IOIQltyInd")]
pub fn ioi_qlty_ind(&self) -> Result<Option<IOIQltyInd<'_>>, InvalidValue> {
Ok(self.0.get_str(Tag(25))?.map(IOIQltyInd::from_value))
}
#[doc(alias = "IOINaturalFlag")]
pub fn ioi_natural_flag(&self) -> Result<Option<bool>, InvalidValue> {
self.0.get_bool(Tag(130))
}
#[doc(alias = "NoIOIQualifiers")]
pub fn ioi_qualifiers(&self) -> Result<Instances<'_, IOIQualGrp<'_>>, InvalidValue> {
self.0.get_group(&IOIQualGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[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))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[doc(alias = "URLLink")]
pub fn url_link(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(149))
}
#[doc(alias = "NoRoutingIDs")]
pub fn routing_ids(&self) -> Result<Instances<'_, RoutingGrp<'_>>, InvalidValue> {
self.0.get_group(&RoutingGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
pub fn spread_or_benchmark_curve_data(&self) -> SpreadOrBenchmarkCurveData<'_> {
SpreadOrBenchmarkCurveData(self.0.scope())
}
pub fn yield_data(&self) -> YieldData<'_> {
YieldData(self.0.scope())
}
}
impl std::fmt::Debug for IOI {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "IOI({})", self.0)
}
}
impl std::fmt::Display for IOI {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}