forked from mirrors/gstreamer-rs
enums: Implement the From trait for error/success
This implements the From trait for all *Error/*Success enums to the corresponding *Return enum.
This commit is contained in:
parent
6325e0fcce
commit
a4f25df045
1 changed files with 48 additions and 0 deletions
|
@ -47,6 +47,12 @@ pub enum StateChangeSuccess {
|
||||||
NoPreroll,
|
NoPreroll,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<StateChangeSuccess> for StateChangeReturn {
|
||||||
|
fn from(value: StateChangeSuccess) -> Self {
|
||||||
|
StateChangeReturn::from_ok(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct StateChangeError;
|
pub struct StateChangeError;
|
||||||
|
@ -57,6 +63,12 @@ impl fmt::Display for StateChangeError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<StateChangeError> for StateChangeReturn {
|
||||||
|
fn from(value: StateChangeError) -> Self {
|
||||||
|
StateChangeReturn::from_error(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Error for StateChangeError {
|
impl Error for StateChangeError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
"Element failed to change its state"
|
"Element failed to change its state"
|
||||||
|
@ -115,6 +127,12 @@ pub enum FlowSuccess {
|
||||||
Ok,
|
Ok,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<FlowSuccess> for FlowReturn {
|
||||||
|
fn from(value: FlowSuccess) -> Self {
|
||||||
|
FlowReturn::from_ok(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub enum FlowError {
|
pub enum FlowError {
|
||||||
|
@ -135,6 +153,12 @@ impl fmt::Display for FlowError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<FlowError> for FlowReturn {
|
||||||
|
fn from(value: FlowError) -> Self {
|
||||||
|
FlowReturn::from_error(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Error for FlowError {
|
impl Error for FlowError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -188,6 +212,12 @@ impl PadLinkReturn {
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
pub struct PadLinkSuccess;
|
pub struct PadLinkSuccess;
|
||||||
|
|
||||||
|
impl From<PadLinkSuccess> for PadLinkReturn {
|
||||||
|
fn from(value: PadLinkSuccess) -> Self {
|
||||||
|
PadLinkReturn::from_ok(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub enum PadLinkError {
|
pub enum PadLinkError {
|
||||||
|
@ -205,6 +235,12 @@ impl fmt::Display for PadLinkError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<PadLinkError> for PadLinkReturn {
|
||||||
|
fn from(value: PadLinkError) -> Self {
|
||||||
|
PadLinkReturn::from_error(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Error for PadLinkError {
|
impl Error for PadLinkError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -258,6 +294,12 @@ pub enum ClockSuccess {
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ClockSuccess> for ClockReturn {
|
||||||
|
fn from(value: ClockSuccess) -> Self {
|
||||||
|
ClockReturn::from_ok(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub enum ClockError {
|
pub enum ClockError {
|
||||||
|
@ -275,6 +317,12 @@ impl fmt::Display for ClockError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ClockError> for ClockReturn {
|
||||||
|
fn from(value: ClockError) -> Self {
|
||||||
|
ClockReturn::from_error(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Error for ClockError {
|
impl Error for ClockError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
|
|
Loading…
Reference in a new issue