Skip to main content

mlt_core/frames/v01/id/
analyze.rs

1use std::fmt::{Debug, Formatter};
2
3use crate::analyse::{Analyze, StatType};
4use crate::utils::OptSeqOpt;
5use crate::v01::{EncodedId, EncodedIdValue, IdValues, RawId, RawIdValue, RawPresence, StreamMeta};
6
7impl Analyze for EncodedId {
8    fn for_each_stream(&self, cb: &mut dyn FnMut(StreamMeta)) {
9        self.presence.for_each_stream(cb);
10        self.value.for_each_stream(cb);
11    }
12}
13
14impl Analyze for EncodedIdValue {
15    fn for_each_stream(&self, cb: &mut dyn FnMut(StreamMeta)) {
16        match self {
17            EncodedIdValue::Id32(s) | EncodedIdValue::Id64(s) => {
18                s.for_each_stream(cb);
19            }
20        }
21    }
22}
23
24impl Analyze for RawId<'_> {
25    fn for_each_stream(&self, cb: &mut dyn FnMut(StreamMeta)) {
26        self.presence.for_each_stream(cb);
27        self.value.for_each_stream(cb);
28    }
29}
30
31impl Analyze for RawIdValue<'_> {
32    fn for_each_stream(&self, cb: &mut dyn FnMut(StreamMeta)) {
33        match self {
34            Self::Id32(v) | Self::Id64(v) => v.for_each_stream(cb),
35        }
36    }
37}
38
39impl Analyze for RawPresence<'_> {
40    fn for_each_stream(&self, cb: &mut dyn FnMut(StreamMeta)) {
41        self.0.for_each_stream(cb);
42    }
43}
44
45impl Analyze for IdValues {
46    fn collect_statistic(&self, stat: StatType) -> usize {
47        self.0.collect_statistic(stat)
48    }
49}
50
51impl Debug for IdValues {
52    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
53        write!(f, "IdValues({:?})", &OptSeqOpt(Some(&self.0)))
54    }
55}