@@ -156,13 +156,46 @@ impl<'de> Deserialize<'de> for GroupKeys {
156156}
157157
158158/// Lifecycle / flush semantics of a streaming time window.
159- #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
159+ ///
160+ /// `Copy`/`Default`/`Hash`/`Display`/`FromStr` and `#[serde(rename_all =
161+ /// "snake_case")]` (matching this file's `WindowFuncKind` neighbor) were
162+ /// added so a downstream backend's own `WindowType`-shaped serving-time
163+ /// enum (data-plane accumulator config: `Tumbling` default,
164+ /// `"window_type": "tumbling"` wire format, string round-trip via
165+ /// `Display`/`FromStr`) could be retired in favor of this type directly,
166+ /// rather than keeping two independently-maintained enums in sync by hand.
167+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , Serialize , Deserialize , Default ) ]
168+ #[ serde( rename_all = "snake_case" ) ]
160169pub enum WindowKind {
170+ #[ default]
161171 Tumbling ,
162172 Sliding ,
163173 Session ,
164174}
165175
176+ impl std:: fmt:: Display for WindowKind {
177+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
178+ match self {
179+ WindowKind :: Tumbling => write ! ( f, "tumbling" ) ,
180+ WindowKind :: Sliding => write ! ( f, "sliding" ) ,
181+ WindowKind :: Session => write ! ( f, "session" ) ,
182+ }
183+ }
184+ }
185+
186+ impl std:: str:: FromStr for WindowKind {
187+ type Err = String ;
188+
189+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
190+ match s. to_lowercase ( ) . as_str ( ) {
191+ "tumbling" => Ok ( WindowKind :: Tumbling ) ,
192+ "sliding" => Ok ( WindowKind :: Sliding ) ,
193+ "session" => Ok ( WindowKind :: Session ) ,
194+ _ => Err ( format ! ( "Unknown window kind: '{s}'" ) ) ,
195+ }
196+ }
197+ }
198+
166199/// Which data model a `Source` / `AggIntent` operates over.
167200#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
168201pub enum DataModel {
0 commit comments