1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! The preview a search hit carries for the palette's preview band.
/// What the palette's preview band shows of a hit: a heading, short facts
/// side by side, items one per line and the start of its text. Data only; the
/// platform lays it out.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct SearchPreview {
pub title: Option<String>,
pub facts: Vec<String>,
pub lines: Vec<String>,
pub body: Option<String>,
}
impl SearchPreview {
/// A preview headed `title`.
#[must_use]
pub fn titled(title: impl Into<String>) -> Self {
Self {
title: Some(title.into()),
..Self::default()
}
}
/// One more fact beside the others.
#[must_use]
pub fn fact(mut self, fact: impl Into<String>) -> Self {
self.facts.push(fact.into());
self
}
/// One more item line.
#[must_use]
pub fn line(mut self, line: impl Into<String>) -> Self {
self.lines.push(line.into());
self
}
/// The start of its text.
#[must_use]
pub fn body(mut self, body: impl Into<String>) -> Self {
self.body = Some(body.into());
self
}
}