14 releases (9 stable)

5.0.1 Oct 25, 2024
5.0.0 Jan 22, 2024
4.1.1 Jan 15, 2024
4.1.0 Oct 3, 2023
0.1.0 May 10, 2022

#39 in #dos

Download history 23/week @ 2024-07-22 130/week @ 2024-07-29 52/week @ 2024-08-05 31/week @ 2024-08-12 33/week @ 2024-08-19 48/week @ 2024-08-26 34/week @ 2024-09-02 41/week @ 2024-09-09 41/week @ 2024-09-16 101/week @ 2024-09-23 28/week @ 2024-09-30 39/week @ 2024-10-14 124/week @ 2024-10-21 75/week @ 2024-10-28 76/week @ 2024-11-04

314 downloads per month
Used in 22 crates (3 directly)

MIT license

12KB
241 lines

Derive macro for dos-actors UniqueIdentifier trait


lib.rs:

UID

A derive macro that implements the UniqueIdentifier trait.

Examples

Setting the data type and port # to the default values: Vec<f64> and 50_000u32, respectively:

use interface::UID;

#[derive(UID)]
enum Tag {}

The data type and port # are set with:

use interface::UID;

struct Q<T>(std::marker::PhantomData<T>);

enum ID {}

#[derive(UID)]
#[uid(data = Q<ID>, port = 9999)]
enum TU {}

An alias is a type that implements the Read, Write or Size trait of another type that implements the same traits for the same client:

use interface::{UID, Data, Read, Size, Update, Write};

struct Client {}
impl Update for Client {}
impl Write<TU> for Client {
fn write(&mut self) -> Option<Data<TU>> {
None
}
}
impl Read<TU> for Client {
fn read(&mut self, _data: Data<TU>) {}
}
impl Size<TU> for Client {
fn len(&self) -> usize {
1234
}
}

#[derive(UID)]
#[alias(name = TU, client = Client, traits = Write, Read, Size)]
enum TUT {}

Dependencies

~205–640KB
~15K SLoC