krisprice / ipnet

IpNet, Ipv4Net, and Ipv6Net types and methods for Rust
Apache License 2.0
122 stars 26 forks source link

Add ser_as_str feature to serialize using serialize_str() #52

Closed elrafoon closed 1 year ago

elrafoon commented 1 year ago

I'm doing a lot of no_std firmware development, and frequently use serde_json_core crate.

This serializer does not support collect_str() used in ipnet's serialization code since 1096c55d6f0b95e06aaa21604c936e3093a40af7.

This patch adds new feature to enable serialization by formatting Ipv*Net addr to heapless::String and then serializing using serialize_str(). Since maximum formatted address length is fixed, and not too big, memory usage is still very low.

krisprice commented 1 year ago

Merged and published on crates.io, thanks @elrafoon

elrafoon commented 1 year ago

Thanks!