From cf9e875878f62c05b7f01e50d05ce19cd9e263e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 6 Aug 2018 11:25:07 +0300 Subject: [PATCH] Implement Ord/PartialOrd on Seqnum --- gstreamer/src/event.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 4df110538..8183f6368 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -58,6 +58,27 @@ impl From for Seqnum { } } +impl cmp::PartialOrd for Seqnum { + fn partial_cmp(&self, other: &Seqnum) -> Option { + Some(self.cmp(other)) + } +} + +impl cmp::Ord for Seqnum { + fn cmp(&self, other: &Seqnum) -> cmp::Ordering { + unsafe { + let ret = ffi::gst_util_seqnum_compare(self.0, other.0); + if ret < 0 { + cmp::Ordering::Less + } else if ret > 0 { + cmp::Ordering::Greater + } else { + cmp::Ordering::Equal + } + } + } +} + #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] pub struct GroupId(pub u32); pub const GROUP_ID_INVALID: GroupId = GroupId(0);