[−][src]Derive Macro amadeus::prelude::data::Data
#[derive(Data)] { // Attributes available to this derive: #[amadeus] }
This is a procedural macro to derive the Data
trait on
structs and enums.
Example
use amadeus::record::Data;
#[derive(Data, Debug)]
struct MyRow {
id: u64,
time: Timestamp,
event: String,
}
If the Rust field name and the Parquet field name differ, say if the latter is not an idiomatic or valid identifier in Rust, then an automatic rename can be made like so:
#[derive(Data, Debug)]
struct MyRow {
#[amadeus(rename = "ID")]
id: u64,
time: Timestamp,
event: String,
}
Implementation
This macro works by creating two new structs: StructSchema and StructReader
(where "Struct" is the name of the user's struct). These structs implement the
Schema
and Reader
traits
respectively. Data
can then be implemented on the
user's struct.