#telescope #astronomy

macro dos-uid-derive

dos-actors UniqueIdentifier derive macro

10 releases (4 major breaking)

4.0.0 Sep 14, 2023
3.0.0 Sep 10, 2023
2.0.0 Mar 10, 2023
1.0.2 Feb 12, 2023
0.1.0 May 10, 2022

#222 in Simulation

Download history 123/week @ 2023-06-03 66/week @ 2023-06-10 177/week @ 2023-06-17 122/week @ 2023-06-24 186/week @ 2023-07-01 235/week @ 2023-07-08 116/week @ 2023-07-15 145/week @ 2023-07-22 51/week @ 2023-07-29 98/week @ 2023-08-05 117/week @ 2023-08-12 54/week @ 2023-08-19 81/week @ 2023-08-26 113/week @ 2023-09-02 261/week @ 2023-09-09 111/week @ 2023-09-16

566 downloads per month
Used in 20 crates (3 directly)

MIT license

10KB
189 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 gmt_dos_clients::interface::UID;

#[derive(UID)]
enum Tag {}

The data type and port # are set with:

use gmt_dos_clients::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 gmt_dos_clients::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)]
#[uid(data = Q<ID>, port = 999)]
#[alias(name = TU, client = Client, traits = Write, Read, Size)]
enum TUT {}

Dependencies

~365–790KB
~19K SLoC