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
30
31
32
33
34
35
36
37
use core::ffi::c_char;

#[allow(missing_docs)]
#[derive(Clone, Copy, Hash, Debug, Eq, PartialEq)]
/// An encoder preset, which should handle most of the configuration.
pub enum Preset {
    Ultrafast,
    Superfast,
    Veryfast,
    Faster,
    Fast,
    Medium,
    Slow,
    Slower,
    Veryslow,
    Placebo,
}

impl Preset {
    #[doc(hidden)]
    pub fn to_cstr(self) -> *const c_char {
        use self::Preset::*;

        (match self {
            Ultrafast => b"ultrafast\0" as *const u8,
            Superfast => b"superfast\0" as *const u8,
            Veryfast => b"veryfast\0" as *const u8,
            Faster => b"faster\0" as *const u8,
            Fast => b"fast\0" as *const u8,
            Medium => b"medium\0" as *const u8,
            Slow => b"slow\0" as *const u8,
            Slower => b"slower\0" as *const u8,
            Veryslow => b"veryslow\0" as *const u8,
            Placebo => b"placebo\0" as *const u8,
        }) as *const c_char
    }
}