From 23a776ea63167b4f758e446742bc077a6efdd5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 28 Feb 2019 20:34:31 +0200 Subject: [PATCH] sdp: Remove return value from various media setter/adder functions They can't possibly fail. --- gstreamer-sdp/src/sdp_media.rs | 79 ++++++++-------------------------- 1 file changed, 18 insertions(+), 61 deletions(-) diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index d1649b9ec..7280a5d05 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -124,29 +124,16 @@ unsafe impl Send for SDPMediaRef {} unsafe impl Sync for SDPMediaRef {} impl SDPMediaRef { - pub fn add_attribute<'a, P: Into>>( - &mut self, - key: &str, - value: P, - ) -> Result<(), ()> { + pub fn add_attribute<'a, P: Into>>(&mut self, key: &str, value: P) { let value = value.into(); let value = value.to_glib_none(); - let result = - unsafe { ffi::gst_sdp_media_add_attribute(&mut self.0, key.to_glib_none().0, value.0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + unsafe { ffi::gst_sdp_media_add_attribute(&mut self.0, key.to_glib_none().0, value.0) }; } - pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) -> Result<(), ()> { - let result = unsafe { + pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) { + unsafe { ffi::gst_sdp_media_add_bandwidth(&mut self.0, bwtype.to_glib_none().0, bandwidth) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } pub fn add_connection( @@ -156,8 +143,8 @@ impl SDPMediaRef { address: &str, ttl: u32, addr_number: u32, - ) -> Result<(), ()> { - let result = unsafe { + ) { + unsafe { ffi::gst_sdp_media_add_connection( &mut self.0, nettype.to_glib_none().0, @@ -167,18 +154,10 @@ impl SDPMediaRef { addr_number, ) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } } - pub fn add_format(&mut self, format: &str) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_media_add_format(&mut self.0, format.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn add_format(&mut self, format: &str) { + unsafe { ffi::gst_sdp_media_add_format(&mut self.0, format.to_glib_none().0) }; } pub fn as_text(&self) -> Option { @@ -556,48 +535,26 @@ impl SDPMediaRef { } } - pub fn set_information(&mut self, information: &str) -> Result<(), ()> { - let result = unsafe { - ffi::gst_sdp_media_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_media_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_media_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_media(&mut self, med: &str) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_media_set_media(&mut self.0, med.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn set_media(&mut self, med: &str) { + unsafe { ffi::gst_sdp_media_set_media(&mut self.0, med.to_glib_none().0) }; } - pub fn set_port_info(&mut self, port: u32, num_ports: u32) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_media_set_port_info(&mut self.0, port, num_ports) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn set_port_info(&mut self, port: u32, num_ports: u32) { + unsafe { ffi::gst_sdp_media_set_port_info(&mut self.0, port, num_ports) }; } - pub fn set_proto(&mut self, proto: &str) -> Result<(), ()> { - let result = unsafe { ffi::gst_sdp_media_set_proto(&mut self.0, proto.to_glib_none().0) }; - match result { - ffi::GST_SDP_OK => Ok(()), - _ => Err(()), - } + pub fn set_proto(&mut self, proto: &str) { + unsafe { ffi::gst_sdp_media_set_proto(&mut self.0, proto.to_glib_none().0) }; } pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> Result<(), ()> {