Closed Sympatron closed 7 months ago
Thank you for the PR @Sympatron. no_std support is here earlier than I anticipated. :) Let me take a look.
I am in the middle of the -sys crate split. I guess it makes sense to merge this and then do the split (otherwise this branch would have way too many conflicts). I will fix any fallouts from this change post merge since no one is using this create ATM.
Sounds good. I just pushed a fix to your comment about Mutex
.
The Rust crate currently depends heavily on
std
. Since OSDP is a protocol mostly for embedded devices I thinkno_std
support is necessary.This PR adds that support by:
core::*
andalloc::*
types instead ofstd::*
where possible."std"
, which users can opt out of. Things likeUnixChannel
or thefile
API will not be available then.parking_log
andspin
as a replacement forstd::sync::Mutex
. I choseparking_lot
, because it is widely used, cross platform and supportslock_api
and can therefore be used just likespin::Mutex
forno_std
without any changes. The use ofspin
should be temporary, because this is almost never what you really want. In the future we should probably let the user choose the concreteMutex
implementation that makes sense for their platform. I didn't do this, because I wanted to keep the changes backwards compatible for now.Read
andWrite
traits instead ofstd::io::{Read, Write}
, because the latter is notno_std
compatible. I couldn't just replace them withembedded_io::{Read, Write}
either, because those are not object safe and can therefore not be used withBox<dyn ...>
. My traits are just very thin wrappers around the others with blanket implementations for everything implementingstd::io::{Read, Write}
orembedded_io::{Read, Write}
.I am open for discussion about my decisions in this PR. :)