Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kskalski opened this issue May 8, 2024 · 0 comments
Open

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

kskalski opened this issue May 8, 2024 · 0 comments

Comments

@kskalski
Copy link
Contributor

kskalski commented May 8, 2024

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"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant