Type Alias openthread::ot::Ip6Address

source ·
pub type Ip6Address = Ipv6Addr;
Expand description

IPv6 Address Type. Functional equivalent of otsys::otIp6Address.

§NOTES ON SAFETY

Here we are making the assumption that a std::net::Ipv6Addr can be freely and safely transmuted to and from an otIp6Address. Doing this is very convenient. On the face of it, this might seem like a safe assumption: IPv6 addresses are always 16 bytes long, that ought to be fine, right? And, in my testing, it does seem to work.

But thinking more carefully about it it seems that this is not guaranteed to be the case. This is supported by the fact that the rust API appears to avoid what would otherwise be obvious additions, such as a method to return the IPv6 address as a slice (octets() returns a fixed-size array).

As a crutch, I’ve added static assertions in various places to verify my assumptions. This effectively eliminates chances of undefined behavior causing problems, but does so at the expense of failing to compile when those assumptions are not met… So we may want to revisit this approach in the future if this is a big concern.

Aliased Type§

struct Ip6Address { /* private fields */ }