rsynko_memory/
selection.rs1use crate::{
2 Format, FormatPredicate, FormatSelection, InfoRecord, InfoValue, interpret_selection,
3 predicate_accepts,
4};
5use rsynko_media::{FormatPredicateMatchAlg, FormatSelectionApplyAlg, FormatViewAlg, MediaSorts};
6
7#[derive(Clone, Copy, Debug, Default)]
9pub struct ReferenceFormatSelector;
10
11impl MediaSorts for ReferenceFormatSelector {
12 type Value = InfoValue;
13 type Metadata = InfoRecord;
14 type Format = Format;
15 type Artifact = ();
16 type Media = ();
17 type Extraction = ();
18 type Extractor = ();
19 type Predicate = FormatPredicate;
20 type Selection = FormatSelection;
21 type Output = ();
22}
23
24impl FormatViewAlg for ReferenceFormatSelector {
25 fn format_text<'a>(&self, format: &'a Format, key: &str) -> Option<&'a str> {
26 format.text(key)
27 }
28}
29
30impl FormatPredicateMatchAlg for ReferenceFormatSelector {
31 fn format_matches(&self, predicate: &FormatPredicate, format: &Format) -> bool {
32 predicate_accepts(predicate, format)
33 }
34}
35
36impl FormatSelectionApplyAlg for ReferenceFormatSelector {
37 fn select_formats<'a>(
38 &self,
39 formats: &'a [Format],
40 selection: &FormatSelection,
41 ) -> Option<Vec<&'a Format>> {
42 interpret_selection(self, formats, selection)
43 }
44}