Skip to content

Commit

Permalink
Inline NotebookDocumentFilter variants.
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbz00 committed Nov 18, 2023
1 parent 7962ea8 commit df3eeea
Showing 1 changed file with 31 additions and 51 deletions.
82 changes: 31 additions & 51 deletions src/notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,63 +207,43 @@ pub enum Notebook {
NotebookDocumentFilter(NotebookDocumentFilter),
}

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum NotebookDocumentFilter {
ByType(NotebookDocumentFilterByType),
ByScheme(NotebookDocumentFilterByScheme),
ByPattern(NotebookDocumentFilterByPattern),
}

/// A notebook document filter denotes a notebook document by
/// different properties.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentFilterByType {
/// The type of the enclosing notebook.
pub notebook_type: String,
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
#[serde(skip_serializing_if = "Option::is_none")]
pub scheme: Option<String>,
/// A glob pattern.
#[serde(skip_serializing_if = "Option::is_none")]
pub pattern: Option<String>,
}

/// A notebook document filter denotes a notebook document by
/// different properties.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentFilterByScheme {
/// The type of the enclosing notebook.
#[serde(skip_serializing_if = "Option::is_none")]
pub notebook_type: Option<String>,
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
pub scheme: String,
/// A glob pattern.
#[serde(skip_serializing_if = "Option::is_none")]
pub pattern: Option<String>,
}

/// A notebook document filter denotes a notebook document by
/// different properties.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentFilterByPattern {
/// The type of the enclosing notebook.
#[serde(skip_serializing_if = "Option::is_none")]
pub notebook_type: Option<String>,
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
#[serde(skip_serializing_if = "Option::is_none")]
pub scheme: Option<String>,
/// A glob pattern.
pub pattern: String,
pub enum NotebookDocumentFilter {
ByType {
/// The type of the enclosing notebook.
notebook_type: String,
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
#[serde(skip_serializing_if = "Option::is_none")]
scheme: Option<String>,
/// A glob pattern.
#[serde(skip_serializing_if = "Option::is_none")]
pattern: Option<String>,
},
ByScheme {
/// The type of the enclosing notebook.
#[serde(skip_serializing_if = "Option::is_none")]
notebook_type: Option<String>,
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
scheme: String,
/// A glob pattern.
#[serde(skip_serializing_if = "Option::is_none")]
pattern: Option<String>,
},
ByPattern {
/// The type of the enclosing notebook.
#[serde(skip_serializing_if = "Option::is_none")]
notebook_type: Option<String>,
/// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
#[serde(skip_serializing_if = "Option::is_none")]
scheme: Option<String>,
/// A glob pattern.
pattern: String,
},
}

mod notification_params {
Expand Down

0 comments on commit df3eeea

Please sign in to comment.