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
//! Sealed boundary marker trait for visage projections.
//!
//! `impl DjogiVisageOf<M> for V` asserts that `V` is a visage (or the
//! model itself) projecting fields from model `M`. The reflexive blanket
//! `impl<M: Model> DjogiVisageOf<M> for M` lets model-scoped code that
//! expects "something that is-or-projects-M" accept either the raw model
//! or one of its visages uniformly.
//!
//! # Why a seal?
//!
//! Emitted visages live in user crates and must be pairable with their
//! source model at the type level — traversal combinators and filter entry
//! points take `V: DjogiVisageOf<M>` bounds so a visage of `User` cannot
//! accidentally plug into a query over `Post`.
//! The seal prevents hostile downstream code from `impl`-ing
//! `DjogiVisageOf<Post> for UserPublic` and smuggling a mismatched
//! visage past the bound. The `private::Sealed<M>` supertrait is the
//! closed-world gate: only the proc macro (via
//! `::djogi::__private::Sealed`) and the reflexive blanket below reach
//! into it.
//!
//! # Path routing
//!
//! The sealed sub-trait is re-exported through `djogi::__private::Sealed`
//! so the `#[model]` proc macro can emit the two impls (`Sealed<M>` +
//! `DjogiVisageOf<M>`) without the user's crate needing a direct
//! `djogi::visage_boundary` import. This matches the macro-path-routing
//! convention (`feedback_macro_path_routing.md`): macro output goes
//! through `::djogi::*` paths only.
/// Sealed marker: `V` is a visage of model `M`.
///
/// Implemented automatically by `#[model]`-generated code for every
/// emitted visage struct (`UserPublic`, `UserSelfView`, `UserAdmin`,
/// `UserExport`). A reflexive blanket also makes every `M: Model` a
/// visage of itself, so generic code bounded on `V: DjogiVisageOf<M>`
/// composes uniformly across both shapes.
///
/// The trait is sealed via `private::Sealed<M>` — downstream crates
/// cannot add their own impls.
// Reflexive blanket: every Model is a visage of itself.
/// Closed-world seal. Re-exported through `::djogi::__private::VisageSealed`
/// so macro-emitted visage code can satisfy the bound; **not part of the
/// public API surface.** The module is `#[doc(hidden)] pub` because the
/// proc macro emits a cross-crate path through it; downstream code must
/// reach the trait only via the `__private` re-export.
///
/// # Do not implement this trait
///
/// This seal is enforced by convention, not by the compiler — Rust has no
/// way to mark a trait "implementable only inside this crate" when its
/// supertrait must be reachable from a separate proc-macro-emitting
/// crate. Any code that hand-implements `djogi::__private::VisageSealed`
/// (or `djogi::visage_boundary::private::Sealed`) for a type outside the
/// `#[model]` macro's emission is breaking the contract; we reserve the
/// right to break that code in any future release without notice. The
/// existing `__private::apps_seal` / `__private::pk_seal` token
/// surfaces and the `model::__sealed::Sealed` boundary follow the
/// same convention.