sdp: Implement Borrow/BorrowMut/ToOwned for SDPMedia

This commit is contained in:
Sebastian Dröge 2019-02-28 11:26:15 +02:00
parent b6f569d049
commit 7b66325f22

View file

@ -6,6 +6,7 @@
// // option. This file may not be copied, modified, or distributed
// // except according to those terms.
use std::borrow::{Borrow, BorrowMut, ToOwned};
use std::ffi::CStr;
use std::fmt;
use std::mem;
@ -632,6 +633,30 @@ impl SDPMediaRef {
}
}
impl Borrow<SDPMediaRef> for SDPMedia {
fn borrow(&self) -> &SDPMediaRef {
&*self
}
}
impl BorrowMut<SDPMediaRef> for SDPMedia {
fn borrow_mut(&mut self) -> &mut SDPMediaRef {
&mut *self
}
}
impl ToOwned for SDPMediaRef {
type Owned = SDPMedia;
fn to_owned(&self) -> SDPMedia {
unsafe {
let mut ptr = ptr::null_mut();
ffi::gst_sdp_media_copy(&self.0, &mut ptr);
from_glib_full(ptr)
}
}
}
macro_rules! define_iter(
($name:ident, $typ:ty, $get_item:expr, $get_len:expr) => {
#[derive(Debug)]