3 unstable releases

0.2.1 Oct 15, 2021
0.2.0 Oct 14, 2021
0.1.0 Sep 14, 2021

#5 in #libplctag


Used in plctag

MIT license

12KB
211 lines

plctag-derive

macros for plctag

crates.io docs build license

Usage

please use it with plctag

With this crate, the macros derive plctag_core::Decode and plctag_core::Encode for you automatically.

Examples

use plctag_core::RawTag;
use plctag_derive::{Decode, Encode};

#[derive(Debug, Default, Decode, Encode)]
struct MyUDT {
    #[tag(offset=0)]
    a: u32,
    #[tag(offset=4)]
    b: u32,
}


fn main() {
    let tag = RawTag::new("make=system&family=library&name=debug&debug=4", 100).unwrap();
    let res = tag.read(100);
    assert!(res.is_ok());
    let udt: MyUDT = tag.get_value(0).unwrap();
    assert_eq!(udt.a, 4);
    assert_eq!(udt.b, 0);
}

License

MIT

Dependencies

~0.7–1.3MB
~29K SLoC