GithubHelp home page GithubHelp logo

Enable sentences with features about nmea HOT 7 CLOSED

aerorust avatar aerorust commented on June 12, 2024 2
Enable sentences with features

from nmea.

Comments (7)

PegasisForever avatar PegasisForever commented on June 12, 2024

I guess this will be a breaking change? If we make all-sentences the default feature, applications use default-features = false for no-std support will break

from nmea.

elpiel avatar elpiel commented on June 12, 2024

Valid point. Yes it will be, but we'll bump version to 0.5.
We can also include Changelog but I'm not afraid to break the build from minor version updates.

default = ["std", "all-sentences"]
all-sentences = ["...", "vendor-specific"]
vendor-specific = [".."]
...
..
.

from nmea.

Dushistov avatar Dushistov commented on June 12, 2024

What about usage of macros instead of features?

Something like

generate_parser![SentenceType::AAM, SentenceType::ABK];

and that generate nmea parser that parse only AAM and ABK messages,
so compiler+linker in release mode can remove unused part of nmea crate?

Plus it would be nice implement the similar fnctionality for Nmea::create_for_navigation.

This variant of dealing with redundant code allows the compiler to solve the unnecessary code problem,
instead of manually marking of each sentence with feature.

from nmea.

elpiel avatar elpiel commented on June 12, 2024

@Dushistov macros might make it more difficult to use the crate and contribute to the project IMO.
Also, not all tools/ides/editors play nicely with macros.
On no_std crates, I've seen macros used to implement different peripherals but not exposing the internal macros for users to define their own.

It's tedious process to add these features now but explicitly listing them sounds like a very good approach.
Due to the way parsers work, I suppose we can even add "Feature not enabled" error when a sentences is passed which can be parsed but the feature hasn't been enabled.

from nmea.

elpiel avatar elpiel commented on June 12, 2024

There's one more additional benefit that I though of.
We can leave the parsers themselves and just exclude the calling of the parser in the parse_str function.

Compiler will still optimize and remove the unused parser/code, however, if you want to parse a specific sentences in your project which you have excluded from parse_str, then it's your choice and you can do it without enabling the feature.

from nmea.

ekuinox avatar ekuinox commented on June 12, 2024

In my case, I use my own ParseResult-like enumeration type combined with some public parsers instead of using ParseResult. So I think it is a good change to be able to exclude unused sentences from the compilation by means of a feature flag.

from nmea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.