From 0dcaa072a147f95becd177ccbb27da6dc1b8df21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 28 Feb 2019 20:26:31 +0200 Subject: [PATCH] sdp: Fix various add/set functions on SDPMessage to not have a return value These can't possibly fail. --- gstreamer-sdp/src/sdp_message.rs | 124 ++++++++----------------------- 1 file changed, 30 insertions(+), 94 deletions(-) diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index 2fd9b9237..d57571de7 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -168,56 +168,35 @@ unsafe impl Send for SDPMessageRef {} unsafe impl Sync for SDPMessageRef {} impl SDPMessageRef { - pub fn add_attribute<'a, P: Into>>( - &mut self, - key: &str, - value: P, - ) -> Result<(), ()> { - let result = unsafe { + pub fn add_attribute<'a, P: Into>>(&mut self, key: &str, value: P) { + unsafe { ffi::gst_sdp_message_add_attribute( &mut self.0, key.to_glib_none().0, value.into().to_glib_none().0, - ) - }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), + ); } } - pub fn add_email(&mut self, email: &str) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_message_add_email(&mut self.0, email.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn add_email(&mut self, email: &str) { + unsafe { ffi::gst_sdp_message_add_email(&mut self.0, email.to_glib_none().0) }; } - pub fn add_media(&mut self, media: SDPMedia) -> Result<(), ()> { - let result = unsafe { + pub fn add_media(&mut self, media: SDPMedia) { + unsafe { ffi::gst_sdp_message_add_media( &mut self.0, media.to_glib_full() as *mut ffi::GstSDPMedia, - ) - }; - mem::forget(media); - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), + ); } } - pub fn add_phone(&mut self, phone: &str) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_message_add_phone(&mut self.0, phone.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn add_phone(&mut self, phone: &str) { + unsafe { ffi::gst_sdp_message_add_phone(&mut self.0, phone.to_glib_none().0) }; } - pub fn add_time(&mut self, start: &str, stop: &str, repeat: &[&str]) -> Result<(), ()> { - let result = unsafe { + pub fn add_time(&mut self, start: &str, stop: &str, repeat: &[&str]) { + unsafe { ffi::gst_sdp_message_add_time( &mut self.0, start.to_glib_none().0, @@ -225,24 +204,16 @@ impl SDPMessageRef { repeat.to_glib_none().0, ) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } - pub fn add_zone(&mut self, adj_time: &str, typed_time: &str) -> Result<(), ()> { - let result = unsafe { + pub fn add_zone(&mut self, adj_time: &str, typed_time: &str) { + unsafe { ffi::gst_sdp_message_add_zone( &mut self.0, adj_time.to_glib_none().0, typed_time.to_glib_none().0, ) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } pub fn as_text(&self) -> Option { @@ -265,12 +236,8 @@ impl SDPMessageRef { unsafe { ffi::gst_sdp_message_bandwidths_len(&self.0) } } - pub fn dump(&self) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_message_dump(&self.0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn dump(&self) { + unsafe { ffi::gst_sdp_message_dump(&self.0) }; } pub fn emails_len(&self) -> u32 { @@ -776,8 +743,8 @@ impl SDPMessageRef { address: &str, ttl: u32, addr_number: u32, - ) -> Result<(), ()> { - let result = unsafe { + ) { + unsafe { ffi::gst_sdp_message_set_connection( &mut self.0, nettype.to_glib_none().0, @@ -787,30 +754,16 @@ impl SDPMessageRef { addr_number, ) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } - pub fn set_information(&mut self, information: &str) -> Result<(), ()> { - let result = unsafe { - ffi::gst_sdp_message_set_information(&mut self.0, information.to_glib_none().0) - }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn set_information(&mut self, information: &str) { + unsafe { ffi::gst_sdp_message_set_information(&mut self.0, information.to_glib_none().0) }; } - pub fn set_key(&mut self, type_: &str, data: &str) -> Result<(), ()> { - let result = unsafe { + pub fn set_key(&mut self, type_: &str, data: &str) { + unsafe { ffi::gst_sdp_message_set_key(&mut self.0, type_.to_glib_none().0, data.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } pub fn set_origin( @@ -821,8 +774,8 @@ impl SDPMessageRef { nettype: &str, addrtype: &str, addr: &str, - ) -> Result<(), ()> { - let result = unsafe { + ) { + unsafe { ffi::gst_sdp_message_set_origin( &mut self.0, username.to_glib_none().0, @@ -833,37 +786,20 @@ impl SDPMessageRef { addr.to_glib_none().0, ) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } - pub fn set_session_name(&mut self, session_name: &str) -> Result<(), ()> { - let result = unsafe { + pub fn set_session_name(&mut self, session_name: &str) { + unsafe { ffi::gst_sdp_message_set_session_name(&mut self.0, session_name.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } - pub fn set_uri(&mut self, uri: &str) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_message_set_uri(&mut self.0, uri.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn set_uri(&mut self, uri: &str) { + unsafe { ffi::gst_sdp_message_set_uri(&mut self.0, uri.to_glib_none().0) }; } - pub fn set_version(&mut self, version: &str) -> Result<(), ()> { - let result = - unsafe { ffi::gst_sdp_message_set_version(&mut self.0, version.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn set_version(&mut self, version: &str) { + unsafe { ffi::gst_sdp_message_set_version(&mut self.0, version.to_glib_none().0) }; } pub fn times_len(&self) -> u32 {