stackaddr

Self-describing, layered address representation library, designed with flexibility and extensibility.
stackaddr
provides a type-safe, composable, and future-proof way to represent network addresses and protocol stacks.
Features
- Layered protocol stack: supports multiple encapsulated protocols (e.g.
/ip4/127.0.0.1/udp/4433/quic
)- Supports from L2 (MAC) to application-level protocols (e.g.
/mac/aa:bb:cc:dd:ee:ff/ip4/192.168.1.1/tcp/80/http
)
- Supports from L2 (MAC) to application-level protocols (e.g.
- Identity aware: supports cryptographic identities like NodeId, PeerId, and UUID
- Strong typing: no ambiguity between TCP/UDP/DNS/etc.
- Serde support(optional): enable with
features = ["serde"]
- Easy parsing: implements
FromStr
,Display
, and error types for easy parsing
Usage
Add stackaddr
to your dependencies:
[]
= "0.1"
To enable serde support:
[dependencies]
stackaddr = { version = "0.1", features = ["serde"] }
Example
Basic:
use ;
let addr = new;
println!;
// Output: /ip4/192.168.10.1/tcp/443/https
From L2 to L4:
let s = "/mac/aa:bb:cc:dd:ee:ff/ip4/192.168.1.1/tcp/8080";
let addr: StackAddr = s.parse.expect;
let expected = new;
assert_eq!;
Parsing from string:
let parsed: StackAddr = "/ip6/::1/tcp/8443".parse.unwrap;
assert_eq!;
With identity:
let public_key: = generate_public_key;
let id = copy_from_slice;
let stack = new;
Acknowledgment
Inspired by Multiaddr, StackAddr inherits its core ideas while embracing Rust’s flexibility to provide a more general-purpose and extensible address representation.