1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Authored record input shared by the macro and source discovery.
use std::collections::BTreeMap;
use syn::{Attribute, Ident, Type, Visibility};
/// One authored field and its history, documentation, lint, and derive helpers.
#[derive(Clone)]
pub struct NamedField {
/// Authored field name.
pub name: Ident,
/// Current or final historical Rust type.
pub ty: Type,
/// Attributes before history consumption.
pub attributes: Vec<Attribute>,
}
/// Native trait derives applied uniformly to every retained payload.
///
/// These generation options do not affect schemas or stored values. Both
/// options default to true, preserving the usual native field semantics.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RecordDerives {
/// Generate the standard field-wise `Debug` implementation.
pub debug: bool,
/// Generate the standard field-wise `PartialEq` implementation.
pub partial_eq: bool,
}
impl Default for RecordDerives {
fn default() -> Self {
Self {
debug: true,
partial_eq: true,
}
}
}
/// Complete inventory used to infer and generate one record history.
pub struct RecordInput {
/// Name of the current alias.
pub name: Ident,
/// Visibility of concrete versions and the current alias.
pub visibility: Visibility,
/// Shape-neutral record attributes.
pub attributes: Vec<Attribute>,
/// Native trait configuration for every retained version. Use
/// `RecordDerives::default()` to retain the standard generated traits.
pub derives: RecordDerives,
/// Every retained field lifetime, including removed fields.
pub fields: Vec<NamedField>,
/// Visibility for every canonical authored field name.
pub field_visibility: BTreeMap<String, Visibility>,
}