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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pub use crate::bindings::windows::media::transcoding::TranscodeFailureReason;
pub type TranscodeResult<T> = Result<T, TranscodeError>;
#[derive(Debug)]
pub enum TranscodeError {
WinRt(winrt::Error),
Io(std::io::Error),
NonUtf8Path,
PrepareTranscodeFailure(TranscodeFailureReason),
}
impl From<winrt::Error> for TranscodeError {
fn from(e: winrt::Error) -> Self {
Self::WinRt(e)
}
}
impl From<std::io::Error> for TranscodeError {
fn from(e: std::io::Error) -> Self {
Self::Io(e)
}
}
impl std::fmt::Display for TranscodeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::WinRt(e) => e.message().fmt(f),
Self::Io(e) => e.fmt(f),
Self::NonUtf8Path => "A non-ut8 path was used by this library.".fmt(f),
Self::PrepareTranscodeFailure(TranscodeFailureReason::None) => {
"No transcode prepare failure.".fmt(f)
}
Self::PrepareTranscodeFailure(TranscodeFailureReason::Unknown) => {
"Unknown transcode prepare failure.".fmt(f)
}
Self::PrepareTranscodeFailure(TranscodeFailureReason::InvalidProfile) => {
"Transcode prepare failure, invalid profile".fmt(f)
}
Self::PrepareTranscodeFailure(TranscodeFailureReason::CodecNotFound) => {
"Transcode prepare failure, unknown codec".fmt(f)
}
Self::PrepareTranscodeFailure(_) => "Transcode prepare failure".fmt(f),
}
}
}
impl std::error::Error for TranscodeError {}