epics-gen
epics-gen is a set of helper macros that help developers create parsers for serializing xlsx spreadsheets into data structures and deserializing them as EPICS PVs.
Macros exposed by this library:
- [
FromXlsxRow]: implements support for converting xlsx rows into structures (deserialize)- [
FromXlsxString]: implements [FromXlsxData] trait for xlsx conversion fromXlsxStringtype to target type - [
FromXlsxFloat]: implements [FromXlsxData] trait for conversion fromXlsxFloattype to target type
- [
- [
AsRecord]: implements support for printing the record (serialize)
Including epics-gen in Your Project
Import epics_gen and epics_gen_macros into your project by adding the
following lines to your Cargo.toml. epics_gen_macros contains the macros
needed to derive all the traits in epics-gen.
[]
= "0.1"
= "0.1"
Macros
| Macro | Description |
|---|---|
| [FromXlsxRow] | Converts xlsx table row to a target struct (deserialization). |
| [FromXlsxString] | Converts XlsxString to target type. |
| [FromXlsxFloat] | Converts XlsxFloat to target type. |
| [AsRecord] | Implements as_record function to type (serialization). |
;
let mut workbook: XlsxWorkbook = open_workbook
.expect;
let parser = new
.add_sheet
.add_table
.build;
let parsed: = parser.parse;
Note that an external library [calamine] is used to read and store xlsx
files and data. The used structures and functions from calamine are reexported
in this crate convenience.
AsRecord attributes
| Attribute | Description |
|---|---|
| [rec_name] | Sets record name of struct. |
| [rec_type] | Define record type. |
| [field] | Define field type. |
| [subst] | Define substitution pattern. |
| [repr] | Define representation type of member. |
| [fmt] | Override member format. |
Example: