-
Notifications
You must be signed in to change notification settings - Fork 11
no-std support #55
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
base: main
Are you sure you want to change the base?
no-std support #55
Conversation
|
Please update from main |
src/packet.rs
Outdated
| use super::*; | ||
| use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}; | ||
| use core::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}; | ||
| use socket2::SockAddr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tests should be adjusted to remove the socket2 dependency. Once that is gone, then the tests are also no_std.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. Honestly if core gives us what we need for initializing sockets, I'm in favor of just removing socket2 altogether.
That crate advertises itself as providing a nice cross-platform way to configure sockets with advanced options; if we're not making use of those options, fewer dependencies is faster compiles :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell core::net only supplies the basic address types and does not do any socket initialization unfortunately. So for the receiver and source modules we'd still need something like it.
I have rewritten the tests in packet.rs without using socket2::SockAddr. Perhaps a #![cfg(feature = "std)] flag or similar should be used in the tests/ directory as they still depend on socket2?
Removed dependency on std when the "std" feature is disabled The library can now be compiled with the --no-default-features flag to enable no_std support. The target will have to specify a #[global_allocator] such as [embedded-alloc](https://docs.rs/embedded-alloc/latest/embedded_alloc/) Replace socket2::SockAddr dependency with core::net::SocketAddrV4/6 `pub fn universe_to_ipv4_multicast_addr()` now returns core::net::SocketAddrV4 `pub fn universe_to_ipv6_multicast_addr()` now returns core::net::SocketAddrV6
Dependencies related to the embedded example were removed
- A parsing function that extracts the DMX data would be useful - A packing function is required to make an sACN source example Perhaps these already exist in some form but just need to be made pub, or I have to search a bit more.
|
I have merged the changes from main and removed the example dependencies from the root Cargo.toml. I also removed the socket2 usage from the packet.rs tests, which now pass with the --no-default-features flag. However the tests in the tests directory still depend on socket2. I have now also added my example code. And I feel like some things are missing as far as no_std functionality goes:
|
Removed dependency on std when the "std" feature is disabled
The library can now be compiled with the --no-default-features flag to enable no_std support. The target will have to specify a #[global_allocator] such as
embedded-alloc
Replace socket2::SockAddr dependency with core::net::SocketAddrV4/6
pub fn universe_to_ipv4_multicast_addr()now returns core::net::SocketAddrV4pub fn universe_to_ipv6_multicast_addr()now returns core::net::SocketAddrV6Implements the foundation for #42