1 unstable release

0.1.0 Dec 6, 2020

#23 in #mac-address

MIT license

8KB
167 lines

port-alloc

Installation

Add this package to Cargo.toml of your project. (Check https://crates.io/crates/port-alloc for right version)

[dependencies]
port-alloc = "0.1.0"

Get started

use port_alloc::PortAlloc;
use std::time::Duration;

let allocator = PortAlloc::new(20000, 65535, Duration::from_seconds(60));
allocator.set_alloc_callback(|id: &[u8]| {
   //
});
allocator.set_dealloc_callback(|id: &[u8]| {
   //
});

let mac_address = "abcdabcdabcd".to_owned();
allocator.alloc_timeout(mac_address, Duration::from_seconds(3));
allocator.wait_process_exit().await?;

Dependencies

~5MB
~77K SLoC