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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#[cfg(feature = "flac")]
use flac_sys::{FLAC__StreamEncoderState, FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OK, FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_UNINITIALIZED,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OGG_ERROR, FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA, FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_CLIENT_ERROR,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_IO_ERROR, FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_FRAMING_ERROR,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR};
#[cfg(feature = "libflac")]
use libflac_sys::{FLAC__StreamEncoderState,
FLAC__STREAM_ENCODER_OK as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OK,
FLAC__STREAM_ENCODER_UNINITIALIZED as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_UNINITIALIZED,
FLAC__STREAM_ENCODER_OGG_ERROR as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OGG_ERROR,
FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
FLAC__STREAM_ENCODER_CLIENT_ERROR as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_CLIENT_ERROR,
FLAC__STREAM_ENCODER_IO_ERROR as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_IO_ERROR,
FLAC__STREAM_ENCODER_FRAMING_ERROR as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_FRAMING_ERROR,
FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR as FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR};
use std::convert::TryFrom;
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[repr(u32)]
pub enum FlacEncoderState {
Ok = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OK,
Uninitialized = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_UNINITIALIZED,
OggError = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OGG_ERROR,
VerifyDecoderError = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
VerifyMismatchInAudioData = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
ClientError = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_CLIENT_ERROR,
IoError = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_IO_ERROR,
FramingError = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_FRAMING_ERROR,
MemoryAllocationError = FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
}
impl Into<FLAC__StreamEncoderState> for FlacEncoderState {
fn into(self) -> FLAC__StreamEncoderState {
self as FLAC__StreamEncoderState
}
}
impl TryFrom<FLAC__StreamEncoderState> for FlacEncoderState {
type Error = ();
#[allow(non_upper_case_globals)]
fn try_from(raw: FLAC__StreamEncoderState) -> Result<FlacEncoderState, ()> {
Ok(match raw {
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OK => FlacEncoderState::Ok,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_UNINITIALIZED => FlacEncoderState::Uninitialized,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_OGG_ERROR => FlacEncoderState::OggError,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR => FlacEncoderState::VerifyDecoderError,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA => FlacEncoderState::VerifyMismatchInAudioData,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_CLIENT_ERROR => FlacEncoderState::ClientError,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_IO_ERROR => FlacEncoderState::IoError,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_FRAMING_ERROR => FlacEncoderState::FramingError,
FLAC__StreamEncoderState_FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR => FlacEncoderState::MemoryAllocationError,
_ => return Err(()),
})
}
}