https://github.com/metastable-void/vlan-rs
Clean VLAN ID representation with transparent u16 support, an invalid VLAN Error type, and a value that represents a native VLAN.
https://github.com/metastable-void/vlan-rs
network-programming rust vlan
Last synced: 3 months ago
JSON representation
Clean VLAN ID representation with transparent u16 support, an invalid VLAN Error type, and a value that represents a native VLAN.
- Host: GitHub
- URL: https://github.com/metastable-void/vlan-rs
- Owner: metastable-void
- License: apache-2.0
- Created: 2025-10-11T15:43:05.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-10-21T12:08:34.000Z (9 months ago)
- Last Synced: 2026-03-14T11:30:57.131Z (4 months ago)
- Topics: network-programming, rust, vlan
- Language: Rust
- Homepage: https://crates.io/crates/vlan
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.APACHE
Awesome Lists containing this project
README
# VLAN ID Rust library
Clean VLAN ID representation with transparent u16 support, an invalid VLAN Error type, and a value that represents a native VLAN.
## Usage
```rust
use vlan::MaybeVlanId;
let native = MaybeVlanId::NATIVE;
assert_eq!(native, MaybeVlanId::try_new(0u16).unwrap());
assert!(MaybeVlanId::try_new(4095).is_err());
// memory-level compatibility with u16!
let zero: u16 = 0u16;
let should_be_zero: u16 = unsafe { std::mem::transmute(MaybeVlanId::NATIVE) };
assert_eq!(zero, should_be_zero);
```
## License
Apache 2.0 or MPL 2.0.