diff --git a/Cargo.toml b/Cargo.toml index e87ff6f..76cef74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,8 @@ rand = { version = "0.8.5", optional = true} [features] serde = ["sd","tinyvec/serde"] test_gen = ["rand"] -default = ["all_msgs"] +std = [] +default = ["all_msgs","std"] all_msgs = [ "msg1001", "msg1002", diff --git a/README.md b/README.md index dfad1bc..f29ee29 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ rtcm-rs = { version = "0.9.0", features=["serde"] } rtcm-rs = { version = "0.9.0", default-features=false, features=["msg1001","msg1005"] } ``` +- `no_std`: To disable the standard library, make sure to set default-features to false. +*Disabling the standard library only has the effect of type RtcmError not implementing the Error trait. No dynamic memory allocations are made regardless of whether the standard library is enabled or not* +```toml +rtcm-rs = { version = "0.9.0", default-features=false } +``` + - `test_gen`: This feature is used exclusively for generating tests during library development and is not necessary for library usage. ## Usage diff --git a/src/lib.rs b/src/lib.rs index cde08eb..a615ee4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,7 +74,8 @@ //! //! For a full list of features and capabilities, see the [README](https://github.com/martinhakansson/rtcm-rs/blob/master/README.md). -#![no_std] +// #![no_std] +#![cfg_attr(not(feature = "std"), no_std)] #![forbid(unsafe_code)] //use message::{Message, MessageBuilder}; //use preamble::MessageFrame; diff --git a/src/rtcm_error.rs b/src/rtcm_error.rs index 79a1a7a..d98cde3 100644 --- a/src/rtcm_error.rs +++ b/src/rtcm_error.rs @@ -36,4 +36,6 @@ impl core::fmt::Display for RtcmError { } } } -//should Error implementation be hidden behind a std feature guard? + +#[cfg(feature = "std")] +impl std::error::Error for RtcmError {}