ldanko / easyfix

MIT License
3 stars 7 forks source link

Expose `crate::fields::basic_types` as separable public module #21

Open kskalski opened 4 months ago

kskalski commented 4 months ago

The motivation is to allow reusing it conveniently in own crate, which will contain generated code.

Currently basic_types are not public, but exposed with wildcard * inside easyfix::fields {}, so it's easy to grab just basic types for re-export without also re-exporting other types from easyfix::fields::*.

The way to work around that is to mention all used types for re-export explicitly, e.g. my crate that contains generated code is now:

pub mod deserializer;
pub use easyfix::serializer;

pub mod fields {
    pub use crate::fields::basic_types::*;
    pub mod basic_types {
        pub use easyfix::fields::{
            Amt, Boolean, Char, Country, Currency, Data, DayOfMonth, Decimal, Exchange, FixStr,
            FixString, FixStringError, Float, Int, Language, Length, LocalMktDate, LocalMktTime,
            MonthYear, MultipleCharValue, MultipleStringValue, NaiveDate, NaiveTime, NumInGroup,
            Percentage, Price, PriceOffset, Qty, SeqNum, TagNum, TimePrecision, TimeZone,
            ToFixString, TzTimeOnly, TzTimestamp, Utc, UtcDateOnly, UtcTimeOnly, UtcTimestamp,
            XmlData,
        };
    }

    include!(concat!(env!("OUT_DIR"), "/generated_fields.rs"));
}

pub mod groups {
    include!(concat!(env!("OUT_DIR"), "/generated_groups.rs"));
}

pub mod messages {
    type MsgCat = easyfix::messages::MsgCat;

    include!(concat!(env!("OUT_DIR"), "/generated_messages.rs"));
}