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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! # sassi-macros
//!
//! Support proc-macro crate for Sassi: `#[derive(Cacheable)]` and
//! `#[sassi::trait_impl]`.
//!
//! Ordinary adopters depend on `sassi`, which re-exports these macros.
//!
//! Macros call into `sassi-codegen` for the actual `TokenStream`
//! emission so the codegen logic stays in a regular library crate
//! that downstream macro crates (e.g., `djogi-macros`) can also
//! consume without running into proc-macro-cycle limitations.
use TokenStream;
use ;
use ;
use ;
/// Derive macro for `sassi::Cacheable`.
///
/// Generates:
/// 1. A companion `{StructName}Fields` struct with one
/// `sassi::Field<Self, FieldType>` per declared field.
/// 2. `impl sassi::Cacheable for {StructName}` with:
/// - `Id` = the type of the field literally named `id`.
/// - `fields()` trait method wiring every accessor to its real
/// extractor (so generic `T: Cacheable` callers can construct
/// wired Fields without knowing the concrete type).
/// 3. When `#[cacheable(watermark_field = "...")]` is present, an
/// `impl sassi::DeltaSyncCacheable` whose `Watermark` is the named
/// field's type and whose `watermark()` clones that field.
///
/// Requirements:
/// - Input must be a struct with named fields.
/// - One of the fields must be literally named `id`.
/// - `id`'s type must implement `Hash + Eq + Clone + Ord + Send + Sync + 'static`.
/// - `watermark_field`, when present, must name a field whose type
/// implements `sassi::MonotonicWatermark`.
/// Attribute macro for registering a trait implementation with
/// `Sassi::all_impl::<dyn Trait>()`.
///
/// Apply it to a concrete trait impl:
///
/// ```ignore
/// #[sassi::trait_impl]
/// impl Nameable for User {
/// fn name(&self) -> &str { &self.name }
/// }
/// ```