mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-12 12:32:02 +00:00
fix: use from trait for encoder, codec, loglevel to u32
This commit is contained in:
parent
fec5473244
commit
4029b4fae5
2 changed files with 26 additions and 20 deletions
|
@ -36,12 +36,14 @@ impl Encoder {
|
|||
pub fn as_vec() -> Vec<Self> {
|
||||
vec![Self::X264, Self::Nvenc, Self::Vaapi]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_number(&self) -> u32 {
|
||||
match self {
|
||||
Self::X264 => 0,
|
||||
Self::Nvenc => 1,
|
||||
Self::Vaapi => 2,
|
||||
impl From<&Encoder> for u32 {
|
||||
fn from(value: &Encoder) -> Self {
|
||||
match value {
|
||||
Encoder::X264 => 0,
|
||||
Encoder::Nvenc => 1,
|
||||
Encoder::Vaapi => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,11 +72,13 @@ impl Codec {
|
|||
pub fn as_vec() -> Vec<Self> {
|
||||
vec![Self::H264, Self::H265]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_number(&self) -> u32 {
|
||||
match self {
|
||||
Self::H264 => 0,
|
||||
Self::H265 => 1,
|
||||
impl From<&Codec> for u32 {
|
||||
fn from(value: &Codec) -> Self {
|
||||
match value {
|
||||
Codec::H264 => 0,
|
||||
Codec::H265 => 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,16 +82,6 @@ impl LogLevel {
|
|||
.iter()
|
||||
}
|
||||
|
||||
pub fn as_number(&self) -> u32 {
|
||||
match self {
|
||||
Self::Trace => 0,
|
||||
Self::Debug => 1,
|
||||
Self::Info => 2,
|
||||
Self::Warning => 3,
|
||||
Self::Error => 99,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn colored(&self) -> String {
|
||||
match self {
|
||||
Self::Trace => TermColor::Gray,
|
||||
|
@ -104,9 +94,21 @@ impl LogLevel {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&LogLevel> for u32 {
|
||||
fn from(value: &LogLevel) -> Self {
|
||||
match value {
|
||||
LogLevel::Trace => 0,
|
||||
LogLevel::Debug => 1,
|
||||
LogLevel::Info => 2,
|
||||
LogLevel::Warning => 3,
|
||||
LogLevel::Error => 99,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for LogLevel {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.as_number().cmp(&other.as_number()))
|
||||
Some(u32::from(self).cmp(&other.into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue