platform-switch
Namespace facades for switching between platforms.
Motivation
Sometimes code needs to be shared between a contrainted platform (such as an embedded system) and a target that has a more fully featured environment. This crate provides a series of module wrappers that can be used in combination with cargo manifest feature definitions to switch between options at compile time.
Example
Using thiserror
with defmt
enabled on an embedded system:
[]
= ["std"]
= ["platform-switch/std_error"]
= ["platform-switch/core_error", "platform-switch/defmt"] # Requires nightly
use log as log;
use thiserror as thiserror;
Stable Toolchain
If a stable toolchain is required, thiserror
can be disabled with the following features and attributes:
[]
= ["std"]
= ["thiserror", "platform-switch/std_error"]
= ["platform-switch/defmt"]
= []
use log as log;
use thiserror as thiserror;