// MetaInfo — mirrors NPE MetaInfo.java. // // Carries "info card" style data (knowledge-panel boxes, COVID/election // warning banners, etc.) attached to a stream or search result. Paired URLs // + URL texts — same indices. use url::Url; #[derive(Clone, Debug, Default)] pub struct MetaInfo { title: String, content: String, urls: Vec, url_texts: Vec, } impl MetaInfo { pub fn new() -> Self { Self::default() } pub fn title(&self) -> &str { &self.title } pub fn set_title(&mut self, title: impl Into) -> &mut Self { self.title = title.into(); self } pub fn content(&self) -> &str { &self.content } pub fn set_content(&mut self, content: impl Into) -> &mut Self { self.content = content.into(); self } pub fn urls(&self) -> &[Url] { &self.urls } pub fn url_texts(&self) -> &[String] { &self.url_texts } pub fn add_url(&mut self, url: Url, text: impl Into) -> &mut Self { self.urls.push(url); self.url_texts.push(text.into()); self } }