summa_core/proto_traits/
snippet.rs

1use summa_proto::proto;
2
3use crate::proto_traits::Wrapper;
4
5impl From<tantivy::snippet::Snippet> for Wrapper<proto::Snippet> {
6    fn from(snippet: tantivy::snippet::Snippet) -> Self {
7        Wrapper::from(proto::Snippet {
8            fragment: snippet.fragment().as_bytes().to_vec(),
9            highlights: snippet
10                .highlighted()
11                .iter()
12                .map(|r| proto::Highlight {
13                    from: r.start as u32,
14                    to: r.end as u32,
15                })
16                .collect(),
17            html: snippet.to_html(),
18        })
19    }
20}