Skip to content

Commit 5205566

Browse files
committed
Inline By* variants.
1 parent e76ca47 commit 5205566

File tree

1 file changed

+51
-79
lines changed

1 file changed

+51
-79
lines changed

src/notebook.rs

+51-79
Original file line numberDiff line numberDiff line change
@@ -164,34 +164,26 @@ pub struct NotebookCellTextDocumentFilter {
164164
}
165165

166166
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
167-
#[serde(untagged)]
167+
#[serde(rename_all = "camelCase", untagged)]
168168
pub enum NotebookSelector {
169-
ByNotebook(NotebookSelectorByNotebook),
170-
ByCells(NotebookSelectorByCells),
171-
}
172-
173-
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
174-
#[serde(rename_all = "camelCase")]
175-
pub struct NotebookSelectorByNotebook {
176-
/// The notebook to be synced. If a string
177-
/// value is provided it matches against the
178-
/// notebook type. '*' matches every notebook.
179-
pub notebook: Notebook,
180-
/// The cells of the matching notebook to be synced.
181-
#[serde(skip_serializing_if = "Option::is_none")]
182-
pub cells: Option<Vec<NotebookCellSelector>>,
183-
}
184-
185-
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
186-
#[serde(rename_all = "camelCase")]
187-
pub struct NotebookSelectorByCells {
188-
/// The notebook to be synced. If a string
189-
/// value is provided it matches against the
190-
/// notebook type. '*' matches every notebook.
191-
#[serde(skip_serializing_if = "Option::is_none")]
192-
pub notebook: Option<Notebook>,
193-
/// The cells of the matching notebook to be synced.
194-
pub cells: Vec<NotebookCellSelector>,
169+
ByNotebook {
170+
/// The notebook to be synced. If a string
171+
/// value is provided it matches against the
172+
/// notebook type. '*' matches every notebook.
173+
notebook: Notebook,
174+
/// The cells of the matching notebook to be synced.
175+
#[serde(skip_serializing_if = "Option::is_none")]
176+
cells: Option<Vec<NotebookCellSelector>>,
177+
},
178+
ByCells {
179+
/// The notebook to be synced. If a string
180+
/// value is provided it matches against the
181+
/// notebook type. '*' matches every notebook.
182+
#[serde(skip_serializing_if = "Option::is_none")]
183+
notebook: Option<Notebook>,
184+
/// The cells of the matching notebook to be synced.
185+
cells: Vec<NotebookCellSelector>,
186+
},
195187
}
196188

197189
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
@@ -207,63 +199,43 @@ pub enum Notebook {
207199
NotebookDocumentFilter(NotebookDocumentFilter),
208200
}
209201

210-
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
211-
#[serde(untagged)]
212-
pub enum NotebookDocumentFilter {
213-
ByType(NotebookDocumentFilterByType),
214-
ByScheme(NotebookDocumentFilterByScheme),
215-
ByPattern(NotebookDocumentFilterByPattern),
216-
}
217-
218-
/// A notebook document filter denotes a notebook document by
219-
/// different properties.
220-
///
221-
/// @since 3.17.0
222-
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
223-
#[serde(rename_all = "camelCase")]
224-
pub struct NotebookDocumentFilterByType {
225-
/// The type of the enclosing notebook.
226-
pub notebook_type: String,
227-
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
228-
#[serde(skip_serializing_if = "Option::is_none")]
229-
pub scheme: Option<String>,
230-
/// A glob pattern.
231-
#[serde(skip_serializing_if = "Option::is_none")]
232-
pub pattern: Option<String>,
233-
}
234-
235202
/// A notebook document filter denotes a notebook document by
236203
/// different properties.
237204
///
238205
/// @since 3.17.0
239206
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
240-
#[serde(rename_all = "camelCase")]
241-
pub struct NotebookDocumentFilterByScheme {
242-
/// The type of the enclosing notebook.
243-
#[serde(skip_serializing_if = "Option::is_none")]
244-
pub notebook_type: Option<String>,
245-
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
246-
pub scheme: String,
247-
/// A glob pattern.
248-
#[serde(skip_serializing_if = "Option::is_none")]
249-
pub pattern: Option<String>,
250-
}
251-
252-
/// A notebook document filter denotes a notebook document by
253-
/// different properties.
254-
///
255-
/// @since 3.17.0
256-
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
257-
#[serde(rename_all = "camelCase")]
258-
pub struct NotebookDocumentFilterByPattern {
259-
/// The type of the enclosing notebook.
260-
#[serde(skip_serializing_if = "Option::is_none")]
261-
pub notebook_type: Option<String>,
262-
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
263-
#[serde(skip_serializing_if = "Option::is_none")]
264-
pub scheme: Option<String>,
265-
/// A glob pattern.
266-
pub pattern: String,
207+
#[serde(rename_all = "camelCase", untagged)]
208+
pub enum NotebookDocumentFilter {
209+
ByType {
210+
/// The type of the enclosing notebook.
211+
notebook_type: String,
212+
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
213+
#[serde(skip_serializing_if = "Option::is_none")]
214+
scheme: Option<String>,
215+
/// A glob pattern.
216+
#[serde(skip_serializing_if = "Option::is_none")]
217+
pattern: Option<String>,
218+
},
219+
ByScheme {
220+
/// The type of the enclosing notebook.
221+
#[serde(skip_serializing_if = "Option::is_none")]
222+
notebook_type: Option<String>,
223+
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
224+
scheme: String,
225+
/// A glob pattern.
226+
#[serde(skip_serializing_if = "Option::is_none")]
227+
pattern: Option<String>,
228+
},
229+
ByPattern {
230+
/// The type of the enclosing notebook.
231+
#[serde(skip_serializing_if = "Option::is_none")]
232+
notebook_type: Option<String>,
233+
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
234+
#[serde(skip_serializing_if = "Option::is_none")]
235+
scheme: Option<String>,
236+
/// A glob pattern.
237+
pattern: String,
238+
},
267239
}
268240

269241
mod notification_params {

0 commit comments

Comments
 (0)