1#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct HostText {
6 pub kind: &'static str,
8 pub text: String,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq)]
14#[non_exhaustive]
15pub enum ClipboardPayload {
16 None,
18 Tsv(String),
20}
21
22impl ClipboardPayload {
23 #[must_use]
25 pub const fn is_none(&self) -> bool {
26 matches!(self, Self::None)
27 }
28}
29
30#[derive(Debug, Clone, PartialEq, Eq)]
32#[non_exhaustive]
33pub struct HostProjection {
34 pub text_nodes: Vec<HostText>,
36 pub clipboard: Option<ClipboardPayload>,
38}
39
40impl HostProjection {
41 pub(crate) fn sealed() -> Self {
42 Self {
43 text_nodes: Vec::new(),
44 clipboard: None,
45 }
46 }
47
48 #[must_use]
50 pub fn audit_text(&self) -> String {
51 let mut s = String::new();
52 for t in &self.text_nodes {
53 s.push_str(&t.text);
54 s.push('\n');
55 }
56 if let Some(ClipboardPayload::Tsv(tsv)) = &self.clipboard {
57 s.push_str(tsv);
58 }
59 s
60 }
61}