Skip to content

Conversation

@deltronix
Copy link

@deltronix deltronix commented Dec 30, 2025

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::SocketAddrV4

pub fn universe_to_ipv6_multicast_addr() now returns core::net::SocketAddrV6

Implements the foundation for #42

@bruingineer
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

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 :)

Copy link
Author

@deltronix deltronix Dec 31, 2025

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.
@deltronix
Copy link
Author

deltronix commented Dec 31, 2025

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:

  • A convenient way to construct sACN packets
  • A convenient way to parse sACN packets. Especially the frames containing DMX data
  • defmt::Format implementations for the packets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants