Crates.io | plctag-derive |
lib.rs | plctag-derive |
version | 0.3.1 |
source | src |
created_at | 2021-09-14 07:22:47.130936 |
updated_at | 2023-01-14 12:46:20.346973 |
description | macros for `plctag` |
homepage | https://github.com/Joylei/plctag-rs |
repository | https://github.com/Joylei/plctag-rs.git |
max_upload_size | |
id | 451080 |
size | 14,776 |
macros for plctag
please use it with plctag
With this crate, the macros derive plctag_core::Decode
and plctag_core::Encode
for you automatically.
use plctag_core::{RawTag, Result, ValueExt};
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);
}
MIT