Crates.io | port-alloc |
lib.rs | port-alloc |
version | 0.1.0 |
source | src |
created_at | 2020-12-06 20:03:39.857666 |
updated_at | 2020-12-06 20:03:39.857666 |
description | port allocator |
homepage | |
repository | |
max_upload_size | |
id | 320218 |
size | 8,455 |
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"
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?;