gstreamer: Mark various enums as exhaustive

This reduces their size to 4 bytes instead of 5 bytes, and as such makes
it possible to store them in a register on 32 bit platforms too.
Additionally it makes it possible for enums like
`Result<FlowSuccess, FlowReturn>` to be stored in a single register on
64 bit platforms.

Also the conversions between the C and Rust type is a simple copy of the
value now instead of a mapping.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1200>
This commit is contained in:
Sebastian Dröge 2023-01-24 11:07:33 +02:00
parent 2c2a6c3871
commit c33fb38ca1
5 changed files with 445 additions and 629 deletions

View file

@ -17,7 +17,6 @@ external_libraries = [
generate = [ generate = [
"Gst.BufferingMode", "Gst.BufferingMode",
"Gst.BusSyncReply",
"Gst.CapsIntersectMode", "Gst.CapsIntersectMode",
"Gst.ClockEntryType", "Gst.ClockEntryType",
"Gst.ClockTimeDiff", "Gst.ClockTimeDiff",
@ -25,8 +24,6 @@ generate = [
"Gst.DebugGraphDetails", "Gst.DebugGraphDetails",
"Gst.EventTypeFlags", "Gst.EventTypeFlags",
"Gst.GapFlags", "Gst.GapFlags",
"Gst.PadMode",
"Gst.PadProbeReturn",
"Gst.ParseError", "Gst.ParseError",
"Gst.PluginAPIFlags", "Gst.PluginAPIFlags",
"Gst.PluginError", "Gst.PluginError",
@ -35,9 +32,7 @@ generate = [
"Gst.PromiseResult", "Gst.PromiseResult",
"Gst.QOSType", "Gst.QOSType",
"Gst.SchedulingFlags", "Gst.SchedulingFlags",
"Gst.SeekType",
"Gst.SerializeFlags", "Gst.SerializeFlags",
"Gst.StateChange",
"Gst.StreamStatusType", "Gst.StreamStatusType",
"Gst.StreamType", "Gst.StreamType",
"Gst.StructureChangeType", "Gst.StructureChangeType",
@ -603,6 +598,11 @@ final_type = true
[object.function.return] [object.function.return]
bool_return_is_error = "Failed to post message" bool_return_is_error = "Failed to post message"
[[object]]
name = "Gst.BusSyncReply"
status = "generate"
exhaustive = true
[[object]] [[object]]
name = "Gst.Caps" name = "Gst.Caps"
status = "manual" status = "manual"
@ -769,6 +769,7 @@ status = "manual"
name = "Gst.ClockReturn" name = "Gst.ClockReturn"
status = "generate" status = "generate"
must_use = true must_use = true
exhaustive = true
[object.conversion_type] [object.conversion_type]
variant = "Result" variant = "Result"
ok_type = "ClockSuccess" ok_type = "ClockSuccess"
@ -1388,8 +1389,10 @@ status = "generate"
[[object]] [[object]]
name = "Gst.FlowReturn" name = "Gst.FlowReturn"
status = "generate" # mapping unknown values to defaults
status = "manual"
must_use = true must_use = true
exhaustive = true
[object.conversion_type] [object.conversion_type]
variant = "Result" variant = "Result"
ok_type = "FlowSuccess" ok_type = "FlowSuccess"
@ -1739,6 +1742,7 @@ manual_traits = ["PadExtManual"]
[[object]] [[object]]
name = "Gst.PadDirection" name = "Gst.PadDirection"
status = "generate" status = "generate"
exhaustive = true
[[object.derive]] [[object.derive]]
name = "serde::Serialize, serde::Deserialize" name = "serde::Serialize, serde::Deserialize"
cfg_condition = "feature = \"serde\"" cfg_condition = "feature = \"serde\""
@ -1760,23 +1764,36 @@ status = "generate"
ignore = true ignore = true
[[object]] [[object]]
# mapping unknown values to default
name = "Gst.PadLinkReturn" name = "Gst.PadLinkReturn"
status = "generate" status = "manual"
must_use = true must_use = true
exhaustive = true
[object.conversion_type] [object.conversion_type]
variant = "Result" variant = "Result"
ok_type = "PadLinkSuccess" ok_type = "PadLinkSuccess"
err_type = "PadLinkError" err_type = "PadLinkError"
[[object]]
name = "Gst.PadMode"
status = "generate"
exhaustive = true
[[object]] [[object]]
name = "Gst.PadPresence" name = "Gst.PadPresence"
status = "generate" status = "generate"
exhaustive = true
[[object.derive]] [[object.derive]]
name = "serde::Serialize, serde::Deserialize" name = "serde::Serialize, serde::Deserialize"
cfg_condition = "feature = \"serde\"" cfg_condition = "feature = \"serde\""
[[object.derive]] [[object.derive]]
name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash"
[[object]]
name = "Gst.PadProbeReturn"
status = "generate"
exhaustive = true
[[object]] [[object]]
name = "Gst.PadProbeType" name = "Gst.PadProbeType"
status = "generate" status = "generate"
@ -2098,6 +2115,11 @@ status = "generate"
name = "none" name = "none"
ignore = true ignore = true
[[object]]
name = "Gst.SeekType"
status = "generate"
exhaustive = true
[[object]] [[object]]
name = "Gst.SegmentFlags" name = "Gst.SegmentFlags"
status = "generate" status = "generate"
@ -2118,16 +2140,23 @@ status = "generate"
[[object]] [[object]]
name = "Gst.State" name = "Gst.State"
status = "generate" status = "generate"
exhaustive = true
[[object.derive]] [[object.derive]]
name = "serde::Serialize, serde::Deserialize" name = "serde::Serialize, serde::Deserialize"
cfg_condition = "feature = \"serde\"" cfg_condition = "feature = \"serde\""
[[object.derive]] [[object.derive]]
name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash"
[[object]]
name = "Gst.StateChange"
status = "generate"
exhaustive = true
[[object]] [[object]]
name = "Gst.StateChangeReturn" name = "Gst.StateChangeReturn"
status = "generate" status = "generate"
must_use = true must_use = true
exhaustive = true
[object.conversion_type] [object.conversion_type]
variant = "Result" variant = "Result"
ok_type = "StateChangeSuccess" ok_type = "StateChangeSuccess"
@ -2461,6 +2490,7 @@ status = "generate"
[[object]] [[object]]
name = "Gst.URIType" name = "Gst.URIType"
status = "generate" status = "generate"
exhaustive = true
[[object.derive]] [[object.derive]]
name = "serde::Serialize, serde::Deserialize" name = "serde::Serialize, serde::Deserialize"
cfg_condition = "feature = \"serde\"" cfg_condition = "feature = \"serde\""

View file

@ -104,17 +104,15 @@ impl From<BufferingMode> for glib::Value {
} }
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstBusSyncReply")] #[doc(alias = "GstBusSyncReply")]
pub enum BusSyncReply { pub enum BusSyncReply {
#[doc(alias = "GST_BUS_DROP")] #[doc(alias = "GST_BUS_DROP")]
Drop, Drop = ffi::GST_BUS_DROP,
#[doc(alias = "GST_BUS_PASS")] #[doc(alias = "GST_BUS_PASS")]
Pass, Pass = ffi::GST_BUS_PASS,
#[doc(alias = "GST_BUS_ASYNC")] #[doc(alias = "GST_BUS_ASYNC")]
Async, Async = ffi::GST_BUS_ASYNC,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -123,12 +121,7 @@ impl IntoGlib for BusSyncReply {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstBusSyncReply { fn into_glib(self) -> ffi::GstBusSyncReply {
match self { self as ffi::GstBusSyncReply
Self::Drop => ffi::GST_BUS_DROP,
Self::Pass => ffi::GST_BUS_PASS,
Self::Async => ffi::GST_BUS_ASYNC,
Self::__Unknown(value) => value,
}
} }
} }
@ -138,12 +131,8 @@ impl FromGlib<ffi::GstBusSyncReply> for BusSyncReply {
unsafe fn from_glib(value: ffi::GstBusSyncReply) -> Self { unsafe fn from_glib(value: ffi::GstBusSyncReply) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([ffi::GST_BUS_DROP, ffi::GST_BUS_PASS, ffi::GST_BUS_ASYNC].contains(&value));
ffi::GST_BUS_DROP => Self::Drop, std::mem::transmute(value)
ffi::GST_BUS_PASS => Self::Pass,
ffi::GST_BUS_ASYNC => Self::Async,
value => Self::__Unknown(value),
}
} }
} }
@ -364,27 +353,25 @@ impl From<ClockEntryType> for glib::Value {
#[must_use] #[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstClockReturn")] #[doc(alias = "GstClockReturn")]
pub enum ClockReturn { pub enum ClockReturn {
#[doc(alias = "GST_CLOCK_OK")] #[doc(alias = "GST_CLOCK_OK")]
Ok, Ok = ffi::GST_CLOCK_OK,
#[doc(alias = "GST_CLOCK_EARLY")] #[doc(alias = "GST_CLOCK_EARLY")]
Early, Early = ffi::GST_CLOCK_EARLY,
#[doc(alias = "GST_CLOCK_UNSCHEDULED")] #[doc(alias = "GST_CLOCK_UNSCHEDULED")]
Unscheduled, Unscheduled = ffi::GST_CLOCK_UNSCHEDULED,
#[doc(alias = "GST_CLOCK_BUSY")] #[doc(alias = "GST_CLOCK_BUSY")]
Busy, Busy = ffi::GST_CLOCK_BUSY,
#[doc(alias = "GST_CLOCK_BADTIME")] #[doc(alias = "GST_CLOCK_BADTIME")]
Badtime, Badtime = ffi::GST_CLOCK_BADTIME,
#[doc(alias = "GST_CLOCK_ERROR")] #[doc(alias = "GST_CLOCK_ERROR")]
Error, Error = ffi::GST_CLOCK_ERROR,
#[doc(alias = "GST_CLOCK_UNSUPPORTED")] #[doc(alias = "GST_CLOCK_UNSUPPORTED")]
Unsupported, Unsupported = ffi::GST_CLOCK_UNSUPPORTED,
#[doc(alias = "GST_CLOCK_DONE")] #[doc(alias = "GST_CLOCK_DONE")]
Done, Done = ffi::GST_CLOCK_DONE,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -393,17 +380,7 @@ impl IntoGlib for ClockReturn {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstClockReturn { fn into_glib(self) -> ffi::GstClockReturn {
match self { self as ffi::GstClockReturn
Self::Ok => ffi::GST_CLOCK_OK,
Self::Early => ffi::GST_CLOCK_EARLY,
Self::Unscheduled => ffi::GST_CLOCK_UNSCHEDULED,
Self::Busy => ffi::GST_CLOCK_BUSY,
Self::Badtime => ffi::GST_CLOCK_BADTIME,
Self::Error => ffi::GST_CLOCK_ERROR,
Self::Unsupported => ffi::GST_CLOCK_UNSUPPORTED,
Self::Done => ffi::GST_CLOCK_DONE,
Self::__Unknown(value) => value,
}
} }
} }
@ -413,17 +390,18 @@ impl FromGlib<ffi::GstClockReturn> for ClockReturn {
unsafe fn from_glib(value: ffi::GstClockReturn) -> Self { unsafe fn from_glib(value: ffi::GstClockReturn) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_CLOCK_OK => Self::Ok, ffi::GST_CLOCK_OK,
ffi::GST_CLOCK_EARLY => Self::Early, ffi::GST_CLOCK_EARLY,
ffi::GST_CLOCK_UNSCHEDULED => Self::Unscheduled, ffi::GST_CLOCK_UNSCHEDULED,
ffi::GST_CLOCK_BUSY => Self::Busy, ffi::GST_CLOCK_BUSY,
ffi::GST_CLOCK_BADTIME => Self::Badtime, ffi::GST_CLOCK_BADTIME,
ffi::GST_CLOCK_ERROR => Self::Error, ffi::GST_CLOCK_ERROR,
ffi::GST_CLOCK_UNSUPPORTED => Self::Unsupported, ffi::GST_CLOCK_UNSUPPORTED,
ffi::GST_CLOCK_DONE => Self::Done, ffi::GST_CLOCK_DONE
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -1099,134 +1077,6 @@ impl From<EventType> for glib::Value {
} }
} }
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstFlowReturn")]
pub enum FlowReturn {
#[doc(alias = "GST_FLOW_CUSTOM_SUCCESS_2")]
CustomSuccess2,
#[doc(alias = "GST_FLOW_CUSTOM_SUCCESS_1")]
CustomSuccess1,
#[doc(alias = "GST_FLOW_CUSTOM_SUCCESS")]
CustomSuccess,
#[doc(alias = "GST_FLOW_OK")]
Ok,
#[doc(alias = "GST_FLOW_NOT_LINKED")]
NotLinked,
#[doc(alias = "GST_FLOW_FLUSHING")]
Flushing,
#[doc(alias = "GST_FLOW_EOS")]
Eos,
#[doc(alias = "GST_FLOW_NOT_NEGOTIATED")]
NotNegotiated,
#[doc(alias = "GST_FLOW_ERROR")]
Error,
#[doc(alias = "GST_FLOW_NOT_SUPPORTED")]
NotSupported,
#[doc(alias = "GST_FLOW_CUSTOM_ERROR")]
CustomError,
#[doc(alias = "GST_FLOW_CUSTOM_ERROR_1")]
CustomError1,
#[doc(alias = "GST_FLOW_CUSTOM_ERROR_2")]
CustomError2,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl IntoGlib for FlowReturn {
type GlibType = ffi::GstFlowReturn;
fn into_glib(self) -> ffi::GstFlowReturn {
match self {
Self::CustomSuccess2 => ffi::GST_FLOW_CUSTOM_SUCCESS_2,
Self::CustomSuccess1 => ffi::GST_FLOW_CUSTOM_SUCCESS_1,
Self::CustomSuccess => ffi::GST_FLOW_CUSTOM_SUCCESS,
Self::Ok => ffi::GST_FLOW_OK,
Self::NotLinked => ffi::GST_FLOW_NOT_LINKED,
Self::Flushing => ffi::GST_FLOW_FLUSHING,
Self::Eos => ffi::GST_FLOW_EOS,
Self::NotNegotiated => ffi::GST_FLOW_NOT_NEGOTIATED,
Self::Error => ffi::GST_FLOW_ERROR,
Self::NotSupported => ffi::GST_FLOW_NOT_SUPPORTED,
Self::CustomError => ffi::GST_FLOW_CUSTOM_ERROR,
Self::CustomError1 => ffi::GST_FLOW_CUSTOM_ERROR_1,
Self::CustomError2 => ffi::GST_FLOW_CUSTOM_ERROR_2,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstFlowReturn> for FlowReturn {
unsafe fn from_glib(value: ffi::GstFlowReturn) -> Self {
skip_assert_initialized!();
match value {
ffi::GST_FLOW_CUSTOM_SUCCESS_2 => Self::CustomSuccess2,
ffi::GST_FLOW_CUSTOM_SUCCESS_1 => Self::CustomSuccess1,
ffi::GST_FLOW_CUSTOM_SUCCESS => Self::CustomSuccess,
ffi::GST_FLOW_OK => Self::Ok,
ffi::GST_FLOW_NOT_LINKED => Self::NotLinked,
ffi::GST_FLOW_FLUSHING => Self::Flushing,
ffi::GST_FLOW_EOS => Self::Eos,
ffi::GST_FLOW_NOT_NEGOTIATED => Self::NotNegotiated,
ffi::GST_FLOW_ERROR => Self::Error,
ffi::GST_FLOW_NOT_SUPPORTED => Self::NotSupported,
ffi::GST_FLOW_CUSTOM_ERROR => Self::CustomError,
ffi::GST_FLOW_CUSTOM_ERROR_1 => Self::CustomError1,
ffi::GST_FLOW_CUSTOM_ERROR_2 => Self::CustomError2,
value => Self::__Unknown(value),
}
}
}
impl StaticType for FlowReturn {
#[inline]
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_flow_return_get_type()) }
}
}
impl glib::value::ValueType for FlowReturn {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for FlowReturn {
type Checker = glib::value::GenericValueTypeChecker<Self>;
#[inline]
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}
impl ToValue for FlowReturn {
#[inline]
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
}
value
}
#[inline]
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
impl From<FlowReturn> for glib::Value {
#[inline]
fn from(v: FlowReturn) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive] #[non_exhaustive]
@ -1489,17 +1339,15 @@ impl From<LibraryError> for glib::Value {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstPadDirection")] #[doc(alias = "GstPadDirection")]
pub enum PadDirection { pub enum PadDirection {
#[doc(alias = "GST_PAD_UNKNOWN")] #[doc(alias = "GST_PAD_UNKNOWN")]
Unknown, Unknown = ffi::GST_PAD_UNKNOWN,
#[doc(alias = "GST_PAD_SRC")] #[doc(alias = "GST_PAD_SRC")]
Src, Src = ffi::GST_PAD_SRC,
#[doc(alias = "GST_PAD_SINK")] #[doc(alias = "GST_PAD_SINK")]
Sink, Sink = ffi::GST_PAD_SINK,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -1508,12 +1356,7 @@ impl IntoGlib for PadDirection {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstPadDirection { fn into_glib(self) -> ffi::GstPadDirection {
match self { self as ffi::GstPadDirection
Self::Unknown => ffi::GST_PAD_UNKNOWN,
Self::Src => ffi::GST_PAD_SRC,
Self::Sink => ffi::GST_PAD_SINK,
Self::__Unknown(value) => value,
}
} }
} }
@ -1523,12 +1366,8 @@ impl FromGlib<ffi::GstPadDirection> for PadDirection {
unsafe fn from_glib(value: ffi::GstPadDirection) -> Self { unsafe fn from_glib(value: ffi::GstPadDirection) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([ffi::GST_PAD_UNKNOWN, ffi::GST_PAD_SRC, ffi::GST_PAD_SINK].contains(&value));
ffi::GST_PAD_UNKNOWN => Self::Unknown, std::mem::transmute(value)
ffi::GST_PAD_SRC => Self::Src,
ffi::GST_PAD_SINK => Self::Sink,
value => Self::__Unknown(value),
}
} }
} }
@ -1577,124 +1416,16 @@ impl From<PadDirection> for glib::Value {
} }
} }
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstPadLinkReturn")]
pub enum PadLinkReturn {
#[doc(alias = "GST_PAD_LINK_OK")]
Ok,
#[doc(alias = "GST_PAD_LINK_WRONG_HIERARCHY")]
WrongHierarchy,
#[doc(alias = "GST_PAD_LINK_WAS_LINKED")]
WasLinked,
#[doc(alias = "GST_PAD_LINK_WRONG_DIRECTION")]
WrongDirection,
#[doc(alias = "GST_PAD_LINK_NOFORMAT")]
Noformat,
#[doc(alias = "GST_PAD_LINK_NOSCHED")]
Nosched,
#[doc(alias = "GST_PAD_LINK_REFUSED")]
Refused,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl IntoGlib for PadLinkReturn {
type GlibType = ffi::GstPadLinkReturn;
#[inline]
fn into_glib(self) -> ffi::GstPadLinkReturn {
match self {
Self::Ok => ffi::GST_PAD_LINK_OK,
Self::WrongHierarchy => ffi::GST_PAD_LINK_WRONG_HIERARCHY,
Self::WasLinked => ffi::GST_PAD_LINK_WAS_LINKED,
Self::WrongDirection => ffi::GST_PAD_LINK_WRONG_DIRECTION,
Self::Noformat => ffi::GST_PAD_LINK_NOFORMAT,
Self::Nosched => ffi::GST_PAD_LINK_NOSCHED,
Self::Refused => ffi::GST_PAD_LINK_REFUSED,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstPadLinkReturn> for PadLinkReturn {
#[inline]
unsafe fn from_glib(value: ffi::GstPadLinkReturn) -> Self {
skip_assert_initialized!();
match value {
ffi::GST_PAD_LINK_OK => Self::Ok,
ffi::GST_PAD_LINK_WRONG_HIERARCHY => Self::WrongHierarchy,
ffi::GST_PAD_LINK_WAS_LINKED => Self::WasLinked,
ffi::GST_PAD_LINK_WRONG_DIRECTION => Self::WrongDirection,
ffi::GST_PAD_LINK_NOFORMAT => Self::Noformat,
ffi::GST_PAD_LINK_NOSCHED => Self::Nosched,
ffi::GST_PAD_LINK_REFUSED => Self::Refused,
value => Self::__Unknown(value),
}
}
}
impl StaticType for PadLinkReturn {
#[inline]
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_pad_link_return_get_type()) }
}
}
impl glib::value::ValueType for PadLinkReturn {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for PadLinkReturn {
type Checker = glib::value::GenericValueTypeChecker<Self>;
#[inline]
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}
impl ToValue for PadLinkReturn {
#[inline]
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
}
value
}
#[inline]
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
impl From<PadLinkReturn> for glib::Value {
#[inline]
fn from(v: PadLinkReturn) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstPadMode")] #[doc(alias = "GstPadMode")]
pub enum PadMode { pub enum PadMode {
#[doc(alias = "GST_PAD_MODE_NONE")] #[doc(alias = "GST_PAD_MODE_NONE")]
None, None = ffi::GST_PAD_MODE_NONE,
#[doc(alias = "GST_PAD_MODE_PUSH")] #[doc(alias = "GST_PAD_MODE_PUSH")]
Push, Push = ffi::GST_PAD_MODE_PUSH,
#[doc(alias = "GST_PAD_MODE_PULL")] #[doc(alias = "GST_PAD_MODE_PULL")]
Pull, Pull = ffi::GST_PAD_MODE_PULL,
#[doc(hidden)]
__Unknown(i32),
} }
impl PadMode { impl PadMode {
@ -1722,12 +1453,7 @@ impl IntoGlib for PadMode {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstPadMode { fn into_glib(self) -> ffi::GstPadMode {
match self { self as ffi::GstPadMode
Self::None => ffi::GST_PAD_MODE_NONE,
Self::Push => ffi::GST_PAD_MODE_PUSH,
Self::Pull => ffi::GST_PAD_MODE_PULL,
Self::__Unknown(value) => value,
}
} }
} }
@ -1737,12 +1463,13 @@ impl FromGlib<ffi::GstPadMode> for PadMode {
unsafe fn from_glib(value: ffi::GstPadMode) -> Self { unsafe fn from_glib(value: ffi::GstPadMode) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_PAD_MODE_NONE => Self::None, ffi::GST_PAD_MODE_NONE,
ffi::GST_PAD_MODE_PUSH => Self::Push, ffi::GST_PAD_MODE_PUSH,
ffi::GST_PAD_MODE_PULL => Self::Pull, ffi::GST_PAD_MODE_PULL
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -1793,17 +1520,15 @@ impl From<PadMode> for glib::Value {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstPadPresence")] #[doc(alias = "GstPadPresence")]
pub enum PadPresence { pub enum PadPresence {
#[doc(alias = "GST_PAD_ALWAYS")] #[doc(alias = "GST_PAD_ALWAYS")]
Always, Always = ffi::GST_PAD_ALWAYS,
#[doc(alias = "GST_PAD_SOMETIMES")] #[doc(alias = "GST_PAD_SOMETIMES")]
Sometimes, Sometimes = ffi::GST_PAD_SOMETIMES,
#[doc(alias = "GST_PAD_REQUEST")] #[doc(alias = "GST_PAD_REQUEST")]
Request, Request = ffi::GST_PAD_REQUEST,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -1812,12 +1537,7 @@ impl IntoGlib for PadPresence {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstPadPresence { fn into_glib(self) -> ffi::GstPadPresence {
match self { self as ffi::GstPadPresence
Self::Always => ffi::GST_PAD_ALWAYS,
Self::Sometimes => ffi::GST_PAD_SOMETIMES,
Self::Request => ffi::GST_PAD_REQUEST,
Self::__Unknown(value) => value,
}
} }
} }
@ -1827,12 +1547,13 @@ impl FromGlib<ffi::GstPadPresence> for PadPresence {
unsafe fn from_glib(value: ffi::GstPadPresence) -> Self { unsafe fn from_glib(value: ffi::GstPadPresence) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_PAD_ALWAYS => Self::Always, ffi::GST_PAD_ALWAYS,
ffi::GST_PAD_SOMETIMES => Self::Sometimes, ffi::GST_PAD_SOMETIMES,
ffi::GST_PAD_REQUEST => Self::Request, ffi::GST_PAD_REQUEST
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -1882,21 +1603,19 @@ impl From<PadPresence> for glib::Value {
} }
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstPadProbeReturn")] #[doc(alias = "GstPadProbeReturn")]
pub enum PadProbeReturn { pub enum PadProbeReturn {
#[doc(alias = "GST_PAD_PROBE_DROP")] #[doc(alias = "GST_PAD_PROBE_DROP")]
Drop, Drop = ffi::GST_PAD_PROBE_DROP,
#[doc(alias = "GST_PAD_PROBE_OK")] #[doc(alias = "GST_PAD_PROBE_OK")]
Ok, Ok = ffi::GST_PAD_PROBE_OK,
#[doc(alias = "GST_PAD_PROBE_REMOVE")] #[doc(alias = "GST_PAD_PROBE_REMOVE")]
Remove, Remove = ffi::GST_PAD_PROBE_REMOVE,
#[doc(alias = "GST_PAD_PROBE_PASS")] #[doc(alias = "GST_PAD_PROBE_PASS")]
Pass, Pass = ffi::GST_PAD_PROBE_PASS,
#[doc(alias = "GST_PAD_PROBE_HANDLED")] #[doc(alias = "GST_PAD_PROBE_HANDLED")]
Handled, Handled = ffi::GST_PAD_PROBE_HANDLED,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -1905,14 +1624,7 @@ impl IntoGlib for PadProbeReturn {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstPadProbeReturn { fn into_glib(self) -> ffi::GstPadProbeReturn {
match self { self as ffi::GstPadProbeReturn
Self::Drop => ffi::GST_PAD_PROBE_DROP,
Self::Ok => ffi::GST_PAD_PROBE_OK,
Self::Remove => ffi::GST_PAD_PROBE_REMOVE,
Self::Pass => ffi::GST_PAD_PROBE_PASS,
Self::Handled => ffi::GST_PAD_PROBE_HANDLED,
Self::__Unknown(value) => value,
}
} }
} }
@ -1922,14 +1634,15 @@ impl FromGlib<ffi::GstPadProbeReturn> for PadProbeReturn {
unsafe fn from_glib(value: ffi::GstPadProbeReturn) -> Self { unsafe fn from_glib(value: ffi::GstPadProbeReturn) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_PAD_PROBE_DROP => Self::Drop, ffi::GST_PAD_PROBE_DROP,
ffi::GST_PAD_PROBE_OK => Self::Ok, ffi::GST_PAD_PROBE_OK,
ffi::GST_PAD_PROBE_REMOVE => Self::Remove, ffi::GST_PAD_PROBE_REMOVE,
ffi::GST_PAD_PROBE_PASS => Self::Pass, ffi::GST_PAD_PROBE_PASS,
ffi::GST_PAD_PROBE_HANDLED => Self::Handled, ffi::GST_PAD_PROBE_HANDLED
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -2755,17 +2468,15 @@ impl From<ResourceError> for glib::Value {
} }
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstSeekType")] #[doc(alias = "GstSeekType")]
pub enum SeekType { pub enum SeekType {
#[doc(alias = "GST_SEEK_TYPE_NONE")] #[doc(alias = "GST_SEEK_TYPE_NONE")]
None, None = ffi::GST_SEEK_TYPE_NONE,
#[doc(alias = "GST_SEEK_TYPE_SET")] #[doc(alias = "GST_SEEK_TYPE_SET")]
Set, Set = ffi::GST_SEEK_TYPE_SET,
#[doc(alias = "GST_SEEK_TYPE_END")] #[doc(alias = "GST_SEEK_TYPE_END")]
End, End = ffi::GST_SEEK_TYPE_END,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -2774,12 +2485,7 @@ impl IntoGlib for SeekType {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstSeekType { fn into_glib(self) -> ffi::GstSeekType {
match self { self as ffi::GstSeekType
Self::None => ffi::GST_SEEK_TYPE_NONE,
Self::Set => ffi::GST_SEEK_TYPE_SET,
Self::End => ffi::GST_SEEK_TYPE_END,
Self::__Unknown(value) => value,
}
} }
} }
@ -2789,12 +2495,13 @@ impl FromGlib<ffi::GstSeekType> for SeekType {
unsafe fn from_glib(value: ffi::GstSeekType) -> Self { unsafe fn from_glib(value: ffi::GstSeekType) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_SEEK_TYPE_NONE => Self::None, ffi::GST_SEEK_TYPE_NONE,
ffi::GST_SEEK_TYPE_SET => Self::Set, ffi::GST_SEEK_TYPE_SET,
ffi::GST_SEEK_TYPE_END => Self::End, ffi::GST_SEEK_TYPE_END
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -2845,21 +2552,19 @@ impl From<SeekType> for glib::Value {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstState")] #[doc(alias = "GstState")]
pub enum State { pub enum State {
#[doc(alias = "GST_STATE_VOID_PENDING")] #[doc(alias = "GST_STATE_VOID_PENDING")]
VoidPending, VoidPending = ffi::GST_STATE_VOID_PENDING,
#[doc(alias = "GST_STATE_NULL")] #[doc(alias = "GST_STATE_NULL")]
Null, Null = ffi::GST_STATE_NULL,
#[doc(alias = "GST_STATE_READY")] #[doc(alias = "GST_STATE_READY")]
Ready, Ready = ffi::GST_STATE_READY,
#[doc(alias = "GST_STATE_PAUSED")] #[doc(alias = "GST_STATE_PAUSED")]
Paused, Paused = ffi::GST_STATE_PAUSED,
#[doc(alias = "GST_STATE_PLAYING")] #[doc(alias = "GST_STATE_PLAYING")]
Playing, Playing = ffi::GST_STATE_PLAYING,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -2868,14 +2573,7 @@ impl IntoGlib for State {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstState { fn into_glib(self) -> ffi::GstState {
match self { self as ffi::GstState
Self::VoidPending => ffi::GST_STATE_VOID_PENDING,
Self::Null => ffi::GST_STATE_NULL,
Self::Ready => ffi::GST_STATE_READY,
Self::Paused => ffi::GST_STATE_PAUSED,
Self::Playing => ffi::GST_STATE_PLAYING,
Self::__Unknown(value) => value,
}
} }
} }
@ -2885,14 +2583,15 @@ impl FromGlib<ffi::GstState> for State {
unsafe fn from_glib(value: ffi::GstState) -> Self { unsafe fn from_glib(value: ffi::GstState) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_STATE_VOID_PENDING => Self::VoidPending, ffi::GST_STATE_VOID_PENDING,
ffi::GST_STATE_NULL => Self::Null, ffi::GST_STATE_NULL,
ffi::GST_STATE_READY => Self::Ready, ffi::GST_STATE_READY,
ffi::GST_STATE_PAUSED => Self::Paused, ffi::GST_STATE_PAUSED,
ffi::GST_STATE_PLAYING => Self::Playing, ffi::GST_STATE_PLAYING
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -2942,31 +2641,29 @@ impl From<State> for glib::Value {
} }
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstStateChange")] #[doc(alias = "GstStateChange")]
pub enum StateChange { pub enum StateChange {
#[doc(alias = "GST_STATE_CHANGE_NULL_TO_READY")] #[doc(alias = "GST_STATE_CHANGE_NULL_TO_READY")]
NullToReady, NullToReady = ffi::GST_STATE_CHANGE_NULL_TO_READY,
#[doc(alias = "GST_STATE_CHANGE_READY_TO_PAUSED")] #[doc(alias = "GST_STATE_CHANGE_READY_TO_PAUSED")]
ReadyToPaused, ReadyToPaused = ffi::GST_STATE_CHANGE_READY_TO_PAUSED,
#[doc(alias = "GST_STATE_CHANGE_PAUSED_TO_PLAYING")] #[doc(alias = "GST_STATE_CHANGE_PAUSED_TO_PLAYING")]
PausedToPlaying, PausedToPlaying = ffi::GST_STATE_CHANGE_PAUSED_TO_PLAYING,
#[doc(alias = "GST_STATE_CHANGE_PLAYING_TO_PAUSED")] #[doc(alias = "GST_STATE_CHANGE_PLAYING_TO_PAUSED")]
PlayingToPaused, PlayingToPaused = ffi::GST_STATE_CHANGE_PLAYING_TO_PAUSED,
#[doc(alias = "GST_STATE_CHANGE_PAUSED_TO_READY")] #[doc(alias = "GST_STATE_CHANGE_PAUSED_TO_READY")]
PausedToReady, PausedToReady = ffi::GST_STATE_CHANGE_PAUSED_TO_READY,
#[doc(alias = "GST_STATE_CHANGE_READY_TO_NULL")] #[doc(alias = "GST_STATE_CHANGE_READY_TO_NULL")]
ReadyToNull, ReadyToNull = ffi::GST_STATE_CHANGE_READY_TO_NULL,
#[doc(alias = "GST_STATE_CHANGE_NULL_TO_NULL")] #[doc(alias = "GST_STATE_CHANGE_NULL_TO_NULL")]
NullToNull, NullToNull = ffi::GST_STATE_CHANGE_NULL_TO_NULL,
#[doc(alias = "GST_STATE_CHANGE_READY_TO_READY")] #[doc(alias = "GST_STATE_CHANGE_READY_TO_READY")]
ReadyToReady, ReadyToReady = ffi::GST_STATE_CHANGE_READY_TO_READY,
#[doc(alias = "GST_STATE_CHANGE_PAUSED_TO_PAUSED")] #[doc(alias = "GST_STATE_CHANGE_PAUSED_TO_PAUSED")]
PausedToPaused, PausedToPaused = ffi::GST_STATE_CHANGE_PAUSED_TO_PAUSED,
#[doc(alias = "GST_STATE_CHANGE_PLAYING_TO_PLAYING")] #[doc(alias = "GST_STATE_CHANGE_PLAYING_TO_PLAYING")]
PlayingToPlaying, PlayingToPlaying = ffi::GST_STATE_CHANGE_PLAYING_TO_PLAYING,
#[doc(hidden)]
__Unknown(i32),
} }
impl StateChange { impl StateChange {
@ -2994,19 +2691,7 @@ impl IntoGlib for StateChange {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstStateChange { fn into_glib(self) -> ffi::GstStateChange {
match self { self as ffi::GstStateChange
Self::NullToReady => ffi::GST_STATE_CHANGE_NULL_TO_READY,
Self::ReadyToPaused => ffi::GST_STATE_CHANGE_READY_TO_PAUSED,
Self::PausedToPlaying => ffi::GST_STATE_CHANGE_PAUSED_TO_PLAYING,
Self::PlayingToPaused => ffi::GST_STATE_CHANGE_PLAYING_TO_PAUSED,
Self::PausedToReady => ffi::GST_STATE_CHANGE_PAUSED_TO_READY,
Self::ReadyToNull => ffi::GST_STATE_CHANGE_READY_TO_NULL,
Self::NullToNull => ffi::GST_STATE_CHANGE_NULL_TO_NULL,
Self::ReadyToReady => ffi::GST_STATE_CHANGE_READY_TO_READY,
Self::PausedToPaused => ffi::GST_STATE_CHANGE_PAUSED_TO_PAUSED,
Self::PlayingToPlaying => ffi::GST_STATE_CHANGE_PLAYING_TO_PLAYING,
Self::__Unknown(value) => value,
}
} }
} }
@ -3016,19 +2701,20 @@ impl FromGlib<ffi::GstStateChange> for StateChange {
unsafe fn from_glib(value: ffi::GstStateChange) -> Self { unsafe fn from_glib(value: ffi::GstStateChange) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_STATE_CHANGE_NULL_TO_READY => Self::NullToReady, ffi::GST_STATE_CHANGE_NULL_TO_READY,
ffi::GST_STATE_CHANGE_READY_TO_PAUSED => Self::ReadyToPaused, ffi::GST_STATE_CHANGE_READY_TO_PAUSED,
ffi::GST_STATE_CHANGE_PAUSED_TO_PLAYING => Self::PausedToPlaying, ffi::GST_STATE_CHANGE_PAUSED_TO_PLAYING,
ffi::GST_STATE_CHANGE_PLAYING_TO_PAUSED => Self::PlayingToPaused, ffi::GST_STATE_CHANGE_PLAYING_TO_PAUSED,
ffi::GST_STATE_CHANGE_PAUSED_TO_READY => Self::PausedToReady, ffi::GST_STATE_CHANGE_PAUSED_TO_READY,
ffi::GST_STATE_CHANGE_READY_TO_NULL => Self::ReadyToNull, ffi::GST_STATE_CHANGE_READY_TO_NULL,
ffi::GST_STATE_CHANGE_NULL_TO_NULL => Self::NullToNull, ffi::GST_STATE_CHANGE_NULL_TO_NULL,
ffi::GST_STATE_CHANGE_READY_TO_READY => Self::ReadyToReady, ffi::GST_STATE_CHANGE_READY_TO_READY,
ffi::GST_STATE_CHANGE_PAUSED_TO_PAUSED => Self::PausedToPaused, ffi::GST_STATE_CHANGE_PAUSED_TO_PAUSED,
ffi::GST_STATE_CHANGE_PLAYING_TO_PLAYING => Self::PlayingToPlaying, ffi::GST_STATE_CHANGE_PLAYING_TO_PLAYING
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -3079,19 +2765,17 @@ impl From<StateChange> for glib::Value {
#[must_use] #[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstStateChangeReturn")] #[doc(alias = "GstStateChangeReturn")]
pub enum StateChangeReturn { pub enum StateChangeReturn {
#[doc(alias = "GST_STATE_CHANGE_FAILURE")] #[doc(alias = "GST_STATE_CHANGE_FAILURE")]
Failure, Failure = ffi::GST_STATE_CHANGE_FAILURE,
#[doc(alias = "GST_STATE_CHANGE_SUCCESS")] #[doc(alias = "GST_STATE_CHANGE_SUCCESS")]
Success, Success = ffi::GST_STATE_CHANGE_SUCCESS,
#[doc(alias = "GST_STATE_CHANGE_ASYNC")] #[doc(alias = "GST_STATE_CHANGE_ASYNC")]
Async, Async = ffi::GST_STATE_CHANGE_ASYNC,
#[doc(alias = "GST_STATE_CHANGE_NO_PREROLL")] #[doc(alias = "GST_STATE_CHANGE_NO_PREROLL")]
NoPreroll, NoPreroll = ffi::GST_STATE_CHANGE_NO_PREROLL,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -3100,13 +2784,7 @@ impl IntoGlib for StateChangeReturn {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstStateChangeReturn { fn into_glib(self) -> ffi::GstStateChangeReturn {
match self { self as ffi::GstStateChangeReturn
Self::Failure => ffi::GST_STATE_CHANGE_FAILURE,
Self::Success => ffi::GST_STATE_CHANGE_SUCCESS,
Self::Async => ffi::GST_STATE_CHANGE_ASYNC,
Self::NoPreroll => ffi::GST_STATE_CHANGE_NO_PREROLL,
Self::__Unknown(value) => value,
}
} }
} }
@ -3116,13 +2794,14 @@ impl FromGlib<ffi::GstStateChangeReturn> for StateChangeReturn {
unsafe fn from_glib(value: ffi::GstStateChangeReturn) -> Self { unsafe fn from_glib(value: ffi::GstStateChangeReturn) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([
ffi::GST_STATE_CHANGE_FAILURE => Self::Failure, ffi::GST_STATE_CHANGE_FAILURE,
ffi::GST_STATE_CHANGE_SUCCESS => Self::Success, ffi::GST_STATE_CHANGE_SUCCESS,
ffi::GST_STATE_CHANGE_ASYNC => Self::Async, ffi::GST_STATE_CHANGE_ASYNC,
ffi::GST_STATE_CHANGE_NO_PREROLL => Self::NoPreroll, ffi::GST_STATE_CHANGE_NO_PREROLL
value => Self::__Unknown(value), ]
} .contains(&value));
std::mem::transmute(value)
} }
} }
@ -4402,17 +4081,15 @@ impl From<URIError> for glib::Value {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive] #[repr(i32)]
#[doc(alias = "GstURIType")] #[doc(alias = "GstURIType")]
pub enum URIType { pub enum URIType {
#[doc(alias = "GST_URI_UNKNOWN")] #[doc(alias = "GST_URI_UNKNOWN")]
Unknown, Unknown = ffi::GST_URI_UNKNOWN,
#[doc(alias = "GST_URI_SINK")] #[doc(alias = "GST_URI_SINK")]
Sink, Sink = ffi::GST_URI_SINK,
#[doc(alias = "GST_URI_SRC")] #[doc(alias = "GST_URI_SRC")]
Src, Src = ffi::GST_URI_SRC,
#[doc(hidden)]
__Unknown(i32),
} }
#[doc(hidden)] #[doc(hidden)]
@ -4421,12 +4098,7 @@ impl IntoGlib for URIType {
#[inline] #[inline]
fn into_glib(self) -> ffi::GstURIType { fn into_glib(self) -> ffi::GstURIType {
match self { self as ffi::GstURIType
Self::Unknown => ffi::GST_URI_UNKNOWN,
Self::Sink => ffi::GST_URI_SINK,
Self::Src => ffi::GST_URI_SRC,
Self::__Unknown(value) => value,
}
} }
} }
@ -4436,12 +4108,8 @@ impl FromGlib<ffi::GstURIType> for URIType {
unsafe fn from_glib(value: ffi::GstURIType) -> Self { unsafe fn from_glib(value: ffi::GstURIType) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match value { debug_assert!([ffi::GST_URI_UNKNOWN, ffi::GST_URI_SINK, ffi::GST_URI_SRC].contains(&value));
ffi::GST_URI_UNKNOWN => Self::Unknown, std::mem::transmute(value)
ffi::GST_URI_SINK => Self::Sink,
ffi::GST_URI_SRC => Self::Src,
value => Self::__Unknown(value),
}
} }
} }

View file

@ -121,11 +121,9 @@ pub use self::enums::ClockType;
pub use self::enums::CoreError; pub use self::enums::CoreError;
pub use self::enums::DebugLevel; pub use self::enums::DebugLevel;
pub use self::enums::EventType; pub use self::enums::EventType;
pub use self::enums::FlowReturn;
pub use self::enums::Format; pub use self::enums::Format;
pub use self::enums::LibraryError; pub use self::enums::LibraryError;
pub use self::enums::PadDirection; pub use self::enums::PadDirection;
pub use self::enums::PadLinkReturn;
pub use self::enums::PadMode; pub use self::enums::PadMode;
pub use self::enums::PadPresence; pub use self::enums::PadPresence;
pub use self::enums::PadProbeReturn; pub use self::enums::PadProbeReturn;

View file

@ -9,7 +9,7 @@ use glib::{
}; };
use thiserror::Error; use thiserror::Error;
use crate::{ClockReturn, FlowReturn, PadLinkReturn, State, StateChange, StateChangeReturn}; use crate::{ClockReturn, State, StateChange, StateChangeReturn};
macro_rules! impl_return_result_traits { macro_rules! impl_return_result_traits {
($ffi_type:ident, $ret_type:ident, $ok_type:ident, $err_type:ident) => { ($ffi_type:ident, $ret_type:ident, $ok_type:ident, $err_type:ident) => {
@ -74,11 +74,8 @@ impl StateChangeReturn {
#[inline] #[inline]
pub fn into_result(self) -> Result<StateChangeSuccess, StateChangeError> { pub fn into_result(self) -> Result<StateChangeSuccess, StateChangeError> {
match self { match self {
StateChangeReturn::Success => Ok(StateChangeSuccess::Success),
StateChangeReturn::Async => Ok(StateChangeSuccess::Async),
StateChangeReturn::NoPreroll => Ok(StateChangeSuccess::NoPreroll),
StateChangeReturn::Failure => Err(StateChangeError), StateChangeReturn::Failure => Err(StateChangeError),
_ => Err(StateChangeError), _ => Ok(unsafe { std::mem::transmute(self) }),
} }
} }
@ -91,19 +88,16 @@ impl StateChangeReturn {
#[inline] #[inline]
pub fn from_ok(v: StateChangeSuccess) -> Self { pub fn from_ok(v: StateChangeSuccess) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match v { unsafe { std::mem::transmute(v) }
StateChangeSuccess::Success => StateChangeReturn::Success,
StateChangeSuccess::Async => StateChangeReturn::Async,
StateChangeSuccess::NoPreroll => StateChangeReturn::NoPreroll,
}
} }
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[repr(i32)]
pub enum StateChangeSuccess { pub enum StateChangeSuccess {
Success, Success = ffi::GST_STATE_CHANGE_SUCCESS,
Async, Async = ffi::GST_STATE_CHANGE_ASYNC,
NoPreroll, NoPreroll = ffi::GST_STATE_CHANGE_NO_PREROLL,
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
@ -118,114 +112,278 @@ impl_return_result_traits!(
StateChangeError StateChangeError
); );
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[repr(i32)]
#[doc(alias = "GstFlowReturn")]
pub enum FlowReturn {
#[doc(alias = "GST_FLOW_CUSTOM_SUCCESS_2")]
CustomSuccess2 = ffi::GST_FLOW_CUSTOM_SUCCESS_2,
#[doc(alias = "GST_FLOW_CUSTOM_SUCCESS_1")]
CustomSuccess1 = ffi::GST_FLOW_CUSTOM_SUCCESS_1,
#[doc(alias = "GST_FLOW_CUSTOM_SUCCESS")]
CustomSuccess = ffi::GST_FLOW_CUSTOM_SUCCESS,
#[doc(alias = "GST_FLOW_OK")]
Ok = ffi::GST_FLOW_OK,
#[doc(alias = "GST_FLOW_NOT_LINKED")]
NotLinked = ffi::GST_FLOW_NOT_LINKED,
#[doc(alias = "GST_FLOW_FLUSHING")]
Flushing = ffi::GST_FLOW_FLUSHING,
#[doc(alias = "GST_FLOW_EOS")]
Eos = ffi::GST_FLOW_EOS,
#[doc(alias = "GST_FLOW_NOT_NEGOTIATED")]
NotNegotiated = ffi::GST_FLOW_NOT_NEGOTIATED,
#[doc(alias = "GST_FLOW_ERROR")]
Error = ffi::GST_FLOW_ERROR,
#[doc(alias = "GST_FLOW_NOT_SUPPORTED")]
NotSupported = ffi::GST_FLOW_NOT_SUPPORTED,
#[doc(alias = "GST_FLOW_CUSTOM_ERROR")]
CustomError = ffi::GST_FLOW_CUSTOM_ERROR,
#[doc(alias = "GST_FLOW_CUSTOM_ERROR_1")]
CustomError1 = ffi::GST_FLOW_CUSTOM_ERROR_1,
#[doc(alias = "GST_FLOW_CUSTOM_ERROR_2")]
CustomError2 = ffi::GST_FLOW_CUSTOM_ERROR_2,
}
#[doc(hidden)]
impl IntoGlib for FlowReturn {
type GlibType = ffi::GstFlowReturn;
#[inline]
fn into_glib(self) -> ffi::GstFlowReturn {
self as ffi::GstFlowReturn
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstFlowReturn> for FlowReturn {
#[inline]
unsafe fn from_glib(value: ffi::GstFlowReturn) -> Self {
skip_assert_initialized!();
if value < ffi::GST_FLOW_NOT_SUPPORTED
&& (value > ffi::GST_FLOW_CUSTOM_ERROR || value < ffi::GST_FLOW_CUSTOM_ERROR_2)
{
FlowReturn::Error
} else if value > 0
&& (value < ffi::GST_FLOW_CUSTOM_SUCCESS || value > ffi::GST_FLOW_CUSTOM_SUCCESS_2)
{
FlowReturn::Ok
} else {
std::mem::transmute(value)
}
}
}
impl StaticType for FlowReturn {
#[inline]
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_flow_return_get_type()) }
}
}
impl glib::value::ValueType for FlowReturn {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for FlowReturn {
type Checker = glib::value::GenericValueTypeChecker<Self>;
#[inline]
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}
impl ToValue for FlowReturn {
#[inline]
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
}
value
}
#[inline]
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
impl From<FlowReturn> for glib::Value {
#[inline]
fn from(v: FlowReturn) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
impl FlowReturn { impl FlowReturn {
#[inline] #[inline]
pub fn into_result(self) -> Result<FlowSuccess, FlowError> { pub fn into_result(self) -> Result<FlowSuccess, FlowError> {
match self { if self.into_glib() >= 0 {
FlowReturn::CustomSuccess2 => Ok(FlowSuccess::CustomSuccess2), Ok(unsafe { std::mem::transmute(self) })
FlowReturn::CustomSuccess1 => Ok(FlowSuccess::CustomSuccess1), } else {
FlowReturn::CustomSuccess => Ok(FlowSuccess::CustomSuccess), Err(unsafe { std::mem::transmute(self) })
FlowReturn::Ok => Ok(FlowSuccess::Ok),
FlowReturn::NotLinked => Err(FlowError::NotLinked),
FlowReturn::Flushing => Err(FlowError::Flushing),
FlowReturn::Eos => Err(FlowError::Eos),
FlowReturn::NotNegotiated => Err(FlowError::NotNegotiated),
FlowReturn::Error => Err(FlowError::Error),
FlowReturn::NotSupported => Err(FlowError::NotSupported),
FlowReturn::CustomError => Err(FlowError::CustomError),
FlowReturn::CustomError1 => Err(FlowError::CustomError1),
FlowReturn::CustomError2 => Err(FlowError::CustomError2),
_ => Err(FlowError::Error),
} }
} }
#[inline] #[inline]
pub fn from_error(v: FlowError) -> Self { pub fn from_error(v: FlowError) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match v { unsafe { std::mem::transmute(v) }
FlowError::NotLinked => FlowReturn::NotLinked,
FlowError::Flushing => FlowReturn::Flushing,
FlowError::Eos => FlowReturn::Eos,
FlowError::NotNegotiated => FlowReturn::NotNegotiated,
FlowError::Error => FlowReturn::Error,
FlowError::NotSupported => FlowReturn::NotSupported,
FlowError::CustomError => FlowReturn::CustomError,
FlowError::CustomError1 => FlowReturn::CustomError1,
FlowError::CustomError2 => FlowReturn::CustomError2,
}
} }
#[inline] #[inline]
pub fn from_ok(v: FlowSuccess) -> Self { pub fn from_ok(v: FlowSuccess) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match v { unsafe { std::mem::transmute(v) }
FlowSuccess::CustomSuccess2 => FlowReturn::CustomSuccess2,
FlowSuccess::CustomSuccess1 => FlowReturn::CustomSuccess1,
FlowSuccess::CustomSuccess => FlowReturn::CustomSuccess,
FlowSuccess::Ok => FlowReturn::Ok,
}
} }
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[repr(i32)]
pub enum FlowSuccess { pub enum FlowSuccess {
CustomSuccess2, CustomSuccess2 = ffi::GST_FLOW_CUSTOM_SUCCESS_2,
CustomSuccess1, CustomSuccess1 = ffi::GST_FLOW_CUSTOM_SUCCESS_1,
CustomSuccess, CustomSuccess = ffi::GST_FLOW_CUSTOM_SUCCESS,
Ok, Ok = ffi::GST_FLOW_OK,
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
#[must_use] #[must_use]
#[repr(i32)]
pub enum FlowError { pub enum FlowError {
#[error("Pad is not linked")] #[error("Pad is not linked")]
NotLinked, NotLinked = ffi::GST_FLOW_NOT_LINKED,
#[error("Pad is flushing")] #[error("Pad is flushing")]
Flushing, Flushing = ffi::GST_FLOW_FLUSHING,
#[error("Pad is EOS")] #[error("Pad is EOS")]
Eos, Eos = ffi::GST_FLOW_EOS,
#[error("Pad is not negotiated")] #[error("Pad is not negotiated")]
NotNegotiated, NotNegotiated = ffi::GST_FLOW_NOT_NEGOTIATED,
#[error("Some (fatal) error occurred. Element generating this error should post an error message with more details")] #[error("Some (fatal) error occurred. Element generating this error should post an error message with more details")]
Error, Error = ffi::GST_FLOW_ERROR,
#[error("This operation is not supported")] #[error("This operation is not supported")]
NotSupported, NotSupported = ffi::GST_FLOW_NOT_SUPPORTED,
#[error("Elements can use values starting from this (and lower) to define custom error codes")] #[error("Elements can use values starting from this (and lower) to define custom error codes")]
CustomError, CustomError = ffi::GST_FLOW_CUSTOM_ERROR,
#[error("Pre-defined custom error code")] #[error("Pre-defined custom error code")]
CustomError1, CustomError1 = ffi::GST_FLOW_CUSTOM_ERROR_1,
#[error("Pre-defined custom error code")] #[error("Pre-defined custom error code")]
CustomError2, CustomError2 = ffi::GST_FLOW_CUSTOM_ERROR_2,
} }
impl_return_result_traits!(GstFlowReturn, FlowReturn, FlowSuccess, FlowError); impl_return_result_traits!(GstFlowReturn, FlowReturn, FlowSuccess, FlowError);
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[repr(i32)]
#[doc(alias = "GstPadLinkReturn")]
pub enum PadLinkReturn {
#[doc(alias = "GST_PAD_LINK_OK")]
Ok = ffi::GST_PAD_LINK_OK,
#[doc(alias = "GST_PAD_LINK_WRONG_HIERARCHY")]
WrongHierarchy = ffi::GST_PAD_LINK_WRONG_HIERARCHY,
#[doc(alias = "GST_PAD_LINK_WAS_LINKED")]
WasLinked = ffi::GST_PAD_LINK_WAS_LINKED,
#[doc(alias = "GST_PAD_LINK_WRONG_DIRECTION")]
WrongDirection = ffi::GST_PAD_LINK_WRONG_DIRECTION,
#[doc(alias = "GST_PAD_LINK_NOFORMAT")]
Noformat = ffi::GST_PAD_LINK_NOFORMAT,
#[doc(alias = "GST_PAD_LINK_NOSCHED")]
Nosched = ffi::GST_PAD_LINK_NOSCHED,
#[doc(alias = "GST_PAD_LINK_REFUSED")]
Refused = ffi::GST_PAD_LINK_REFUSED,
}
#[doc(hidden)]
impl IntoGlib for PadLinkReturn {
type GlibType = ffi::GstPadLinkReturn;
#[inline]
fn into_glib(self) -> ffi::GstPadLinkReturn {
self as ffi::GstPadLinkReturn
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstPadLinkReturn> for PadLinkReturn {
#[inline]
unsafe fn from_glib(value: ffi::GstPadLinkReturn) -> Self {
skip_assert_initialized!();
if value >= 0 {
PadLinkReturn::Ok
} else if value < ffi::GST_PAD_LINK_REFUSED {
PadLinkReturn::Refused
} else {
std::mem::transmute(value)
}
}
}
impl StaticType for PadLinkReturn {
#[inline]
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_pad_link_return_get_type()) }
}
}
impl glib::value::ValueType for PadLinkReturn {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for PadLinkReturn {
type Checker = glib::value::GenericValueTypeChecker<Self>;
#[inline]
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}
impl ToValue for PadLinkReturn {
#[inline]
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
}
value
}
#[inline]
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
impl From<PadLinkReturn> for glib::Value {
#[inline]
fn from(v: PadLinkReturn) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
impl PadLinkReturn { impl PadLinkReturn {
#[inline] #[inline]
pub fn into_result(self) -> Result<PadLinkSuccess, PadLinkError> { pub fn into_result(self) -> Result<PadLinkSuccess, PadLinkError> {
match self { if self == PadLinkReturn::Ok {
PadLinkReturn::Ok => Ok(PadLinkSuccess), Ok(PadLinkSuccess)
PadLinkReturn::WrongHierarchy => Err(PadLinkError::WrongHierarchy), } else {
PadLinkReturn::WasLinked => Err(PadLinkError::WasLinked), Err(unsafe { std::mem::transmute(self) })
PadLinkReturn::WrongDirection => Err(PadLinkError::WrongDirection),
PadLinkReturn::Noformat => Err(PadLinkError::Noformat),
PadLinkReturn::Nosched => Err(PadLinkError::Nosched),
PadLinkReturn::Refused => Err(PadLinkError::Refused),
_ => Err(PadLinkError::Refused),
} }
} }
#[inline] #[inline]
pub fn from_error(v: PadLinkError) -> Self { pub fn from_error(v: PadLinkError) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match v { unsafe { std::mem::transmute(v) }
PadLinkError::WrongHierarchy => PadLinkReturn::WrongHierarchy,
PadLinkError::WasLinked => PadLinkReturn::WasLinked,
PadLinkError::WrongDirection => PadLinkReturn::WrongDirection,
PadLinkError::Noformat => PadLinkReturn::Noformat,
PadLinkError::Nosched => PadLinkReturn::Nosched,
PadLinkError::Refused => PadLinkReturn::Refused,
}
} }
#[inline] #[inline]
@ -240,19 +398,20 @@ pub struct PadLinkSuccess;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
#[must_use] #[must_use]
#[repr(i32)]
pub enum PadLinkError { pub enum PadLinkError {
#[error("Pads have no common grandparent")] #[error("Pads have no common grandparent")]
WrongHierarchy, WrongHierarchy = ffi::GST_PAD_LINK_WRONG_HIERARCHY,
#[error("Pad was already linked")] #[error("Pad was already linked")]
WasLinked, WasLinked = ffi::GST_PAD_LINK_WAS_LINKED,
#[error("Pads have wrong direction")] #[error("Pads have wrong direction")]
WrongDirection, WrongDirection = ffi::GST_PAD_LINK_WRONG_DIRECTION,
#[error("Pads do not have common format")] #[error("Pads do not have common format")]
Noformat, Noformat = ffi::GST_PAD_LINK_NOFORMAT,
#[error("Pads cannot cooperate in scheduling")] #[error("Pads cannot cooperate in scheduling")]
Nosched, Nosched = ffi::GST_PAD_LINK_NOSCHED,
#[error("Refused for some other reason")] #[error("Refused for some other reason")]
Refused, Refused = ffi::GST_PAD_LINK_REFUSED,
} }
impl_return_result_traits!( impl_return_result_traits!(
@ -268,60 +427,46 @@ impl ClockReturn {
match self { match self {
ClockReturn::Ok => Ok(ClockSuccess::Ok), ClockReturn::Ok => Ok(ClockSuccess::Ok),
ClockReturn::Done => Ok(ClockSuccess::Done), ClockReturn::Done => Ok(ClockSuccess::Done),
ClockReturn::Early => Err(ClockError::Early), _ => Err(unsafe { std::mem::transmute(self) }),
ClockReturn::Unscheduled => Err(ClockError::Unscheduled),
ClockReturn::Busy => Err(ClockError::Busy),
ClockReturn::Badtime => Err(ClockError::Badtime),
ClockReturn::Error => Err(ClockError::Error),
ClockReturn::Unsupported => Err(ClockError::Unsupported),
_ => Err(ClockError::Error),
} }
} }
#[inline] #[inline]
pub fn from_error(v: ClockError) -> Self { pub fn from_error(v: ClockError) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match v { unsafe { std::mem::transmute(v) }
ClockError::Early => ClockReturn::Early,
ClockError::Unscheduled => ClockReturn::Unscheduled,
ClockError::Busy => ClockReturn::Busy,
ClockError::Badtime => ClockReturn::Badtime,
ClockError::Error => ClockReturn::Error,
ClockError::Unsupported => ClockReturn::Unsupported,
}
} }
#[inline] #[inline]
pub fn from_ok(v: ClockSuccess) -> Self { pub fn from_ok(v: ClockSuccess) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
match v { unsafe { std::mem::transmute(v) }
ClockSuccess::Ok => ClockReturn::Ok,
ClockSuccess::Done => ClockReturn::Done,
}
} }
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[repr(i32)]
pub enum ClockSuccess { pub enum ClockSuccess {
Ok, Ok = ffi::GST_CLOCK_OK,
Done, Done = ffi::GST_CLOCK_DONE,
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
#[must_use] #[must_use]
#[repr(i32)]
pub enum ClockError { pub enum ClockError {
#[error("The operation was scheduled too late")] #[error("The operation was scheduled too late")]
Early, Early = ffi::GST_CLOCK_EARLY,
#[error("The clockID was unscheduled")] #[error("The clockID was unscheduled")]
Unscheduled, Unscheduled = ffi::GST_CLOCK_UNSCHEDULED,
#[error("The ClockID is busy")] #[error("The ClockID is busy")]
Busy, Busy = ffi::GST_CLOCK_BUSY,
#[error("A bad time was provided to a function")] #[error("A bad time was provided to a function")]
Badtime, Badtime = ffi::GST_CLOCK_BADTIME,
#[error("An error occurred")] #[error("An error occurred")]
Error, Error = ffi::GST_CLOCK_ERROR,
#[error("Operation is not supported")] #[error("Operation is not supported")]
Unsupported, Unsupported = ffi::GST_CLOCK_UNSUPPORTED,
} }
impl_return_result_traits!(GstClockReturn, ClockReturn, ClockSuccess, ClockError); impl_return_result_traits!(GstClockReturn, ClockReturn, ClockSuccess, ClockError);
@ -707,35 +852,11 @@ impl StateChange {
#[inline] #[inline]
pub fn current(self) -> State { pub fn current(self) -> State {
match self { unsafe { from_glib(self.into_glib() >> 3) }
StateChange::NullToReady => State::Null,
StateChange::ReadyToPaused => State::Ready,
StateChange::PausedToPlaying => State::Paused,
StateChange::PlayingToPaused => State::Playing,
StateChange::PausedToReady => State::Paused,
StateChange::ReadyToNull => State::Ready,
StateChange::NullToNull => State::Null,
StateChange::ReadyToReady => State::Ready,
StateChange::PausedToPaused => State::Paused,
StateChange::PlayingToPlaying => State::Playing,
StateChange::__Unknown(value) => State::__Unknown(value >> 3),
}
} }
#[inline] #[inline]
pub fn next(self) -> State { pub fn next(self) -> State {
match self { unsafe { from_glib(self.into_glib() & 0x7) }
StateChange::NullToReady => State::Ready,
StateChange::ReadyToPaused => State::Paused,
StateChange::PausedToPlaying => State::Playing,
StateChange::PlayingToPaused => State::Paused,
StateChange::PausedToReady => State::Ready,
StateChange::ReadyToNull => State::Null,
StateChange::NullToNull => State::Null,
StateChange::ReadyToReady => State::Ready,
StateChange::PausedToPaused => State::Paused,
StateChange::PlayingToPlaying => State::Playing,
StateChange::__Unknown(value) => State::__Unknown(value & 0x7),
}
} }
} }

View file

@ -180,7 +180,6 @@ mod device_monitor;
mod device_provider; mod device_provider;
mod device_provider_factory; mod device_provider_factory;
mod enums; mod enums;
pub use crate::enums::MessageType;
mod ghost_pad; mod ghost_pad;
mod gobject; mod gobject;
mod iterator; mod iterator;
@ -208,8 +207,8 @@ pub use crate::{
ELEMENT_METADATA_LONGNAME, ELEMENT_METADATA_LONGNAME,
}, },
enums::{ enums::{
ClockError, ClockSuccess, FlowError, FlowSuccess, PadLinkError, PadLinkSuccess, ClockError, ClockSuccess, FlowError, FlowReturn, FlowSuccess, MessageType, PadLinkError,
StateChangeError, StateChangeSuccess, TagError, PadLinkReturn, PadLinkSuccess, StateChangeError, StateChangeSuccess, TagError,
}, },
parse_context::ParseContext, parse_context::ParseContext,
task_pool::{TaskHandle, TaskPoolTaskHandle}, task_pool::{TaskHandle, TaskPoolTaskHandle},