From 4959fae043ce185c66d0dbfc6e42c776237e4e94 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 72db94fad..25a393a6c 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);