av_codec/
common.rs

1/// Defines a series of methods to interact with a list of codec descriptors.
2pub trait CodecList: Sized {
3    /// The type of the structure used to describe a codec.
4    type D: ?Sized;
5
6    /// Creates a new codec list.
7    fn new() -> Self;
8
9    // TODO more lookup functions
10    /// Search by name whether a codec descriptor is in the codec list and
11    /// returns it.
12    ///
13    /// If the requested codec descriptor is not in the list,
14    /// `None` is returned.
15    fn by_name(&self, name: &str) -> Option<&'static Self::D>;
16
17    /// Appends a codec to the list.
18    fn append(&mut self, desc: &'static Self::D);
19
20    /// Creates a new codec list starting from a list of codec descriptors.
21    fn from_list(descs: &[&'static Self::D]) -> Self {
22        let mut c = Self::new();
23        for &desc in descs {
24            c.append(desc);
25        }
26
27        c
28    }
29}