television_previewers/previewers/
basic.rs

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
use std::sync::Arc;

use crate::previewers::{Preview, PreviewContent};
use television_channels::entry::Entry;

#[derive(Debug, Default)]
pub struct BasicPreviewer {
    _config: BasicPreviewerConfig,
}

#[derive(Debug, Default)]
pub struct BasicPreviewerConfig {}

impl BasicPreviewer {
    pub fn new(config: Option<BasicPreviewerConfig>) -> Self {
        BasicPreviewer {
            _config: config.unwrap_or_default(),
        }
    }

    pub fn preview(&self, entry: &Entry) -> Arc<Preview> {
        Arc::new(Preview {
            title: entry.name.clone(),
            content: PreviewContent::PlainTextWrapped(entry.name.clone()),
            icon: entry.icon,
            ..Default::default()
        })
    }
}