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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//! Output type markers for compile-time traversal type tracking.
//!
//! This module provides marker types that track what a traversal produces
//! at compile time, enabling type-safe terminal methods.
//!
//! # Overview
//!
//! When a traversal is executed, its output type determines what the
//! terminal methods return:
//!
//! - `Vertex` marker → `next()` returns `GraphVertex`
//! - `Edge` marker → `next()` returns `GraphEdge`
//! - `Scalar` marker → `next()` returns `Value`
//!
//! # Marker Types
//!
//! | Marker | Description | Terminal Returns |
//! |--------|-------------|------------------|
//! | [`Vertex`] | Traversal produces vertices | `GraphVertex` |
//! | [`Edge`] | Traversal produces edges | `GraphEdge` |
//! | [`Scalar`] | Traversal produces arbitrary values | `Value` |
//!
//! # Type Transformations
//!
//! Navigation and transform steps change the marker type:
//!
//! ```text
//! g.v() → Vertex marker
//! g.v().out_e() → Edge marker (Vertex → Edge)
//! g.v().values() → Scalar marker (Vertex → Scalar)
//! g.e().out_v() → Vertex marker (Edge → Vertex)
//! ```
//!
//! # Example
//!
//! ```ignore
//! use interstellar::traversal::markers::{Vertex, Edge, Scalar, OutputMarker};
//!
//! // Type-level assertions
//! fn vertex_traversal<T: OutputMarker<Output = GraphVertex>>(_t: T) {}
//! fn edge_traversal<T: OutputMarker<Output = GraphEdge>>(_t: T) {}
//! fn scalar_traversal<T: OutputMarker<Output = Value>>(_t: T) {}
//!
//! vertex_traversal(Vertex);
//! edge_traversal(Edge);
//! scalar_traversal(Scalar);
//! ```
use crate;
use crateValue;
// =============================================================================
// Marker Types
// =============================================================================
/// Marker indicating traversal produces vertices.
///
/// When a traversal has this marker, terminal methods like `next()` and
/// `to_list()` return `GraphVertex` objects instead of raw `Value`s.
///
/// # Example
///
/// ```ignore
/// // g.v() produces Vertex marker
/// let v: GraphVertex = g.v().next().unwrap();
///
/// // g.v().out() also produces Vertex marker
/// let friends: Vec<GraphVertex> = g.v().out().to_list();
/// ```
;
/// Marker indicating traversal produces edges.
///
/// When a traversal has this marker, terminal methods like `next()` and
/// `to_list()` return `GraphEdge` objects instead of raw `Value`s.
///
/// # Example
///
/// ```ignore
/// // g.e() produces Edge marker
/// let e: GraphEdge = g.e().next().unwrap();
///
/// // g.v().out_e() also produces Edge marker
/// let edges: Vec<GraphEdge> = g.v().out_e().to_list();
/// ```
;
/// Marker indicating traversal produces arbitrary values.
///
/// When a traversal has this marker, terminal methods return raw `Value`s.
/// This is the default for operations that extract properties or perform
/// aggregations.
///
/// # Example
///
/// ```ignore
/// // g.v().values("name") produces Scalar marker
/// let names: Vec<Value> = g.v().values("name").to_list();
///
/// // g.v().count() produces Scalar marker
/// let count: Value = g.v().count().next().unwrap();
/// ```
;
// =============================================================================
// OutputMarker Trait
// =============================================================================
/// Trait for traversal output markers.
///
/// This trait defines the associated types for terminal method returns
/// based on what the traversal produces.
///
/// # Sealed Trait
///
/// This is a sealed trait - only `Vertex`, `Edge`, and `Scalar` implement it.
/// Users cannot implement this trait for custom types.
///
/// # Associated Types
///
/// - `Output` - The type returned by `next()` and `one()`
/// - `OutputList` - The type returned by `to_list()`
///
/// # Example
///
/// ```ignore
/// use interstellar::traversal::markers::{Vertex, Edge, Scalar, OutputMarker};
///
/// // Vertex marker's Output is GraphVertex
/// type VertexOut = <Vertex as OutputMarker>::Output; // GraphVertex
///
/// // Edge marker's Output is GraphEdge
/// type EdgeOut = <Edge as OutputMarker>::Output; // GraphEdge
///
/// // Scalar marker's Output is Value
/// type ScalarOut = <Scalar as OutputMarker>::Output; // Value
/// ```
// =============================================================================
// Sealed Trait (Private)
// =============================================================================
// =============================================================================
// Tests
// =============================================================================