Skip to main content

Mountain/Command/Hover/Interface/
HoverResponse.rs

1
2//! Outbound hover response DTO: ordered list of `HoverContent::Enum`
3//! plus an optional `Range::Struct` the hover applies to. Range is
4//! omitted in serialised form when absent.
5
6use serde::{Deserialize, Serialize};
7
8use crate::Command::Hover::Interface::{HoverContent, Range};
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Struct {
12	pub contents:Vec<HoverContent::Enum>,
13
14	#[serde(skip_serializing_if = "Option::is_none")]
15	pub range:Option<Range::Struct>,
16}
17
18impl Default for Struct {
19	fn default() -> Self { Self { contents:Vec::new(), range:None } }
20}
21
22impl Struct {
23	pub fn new(contents:Vec<HoverContent::Enum>) -> Self { Self { contents, range:None } }
24
25	pub fn WithRange(contents:Vec<HoverContent::Enum>, range:Range::Struct) -> Self {
26		Self { contents, range:Some(range) }
27	}
28}