gstreamer_sdp/
sdp_origin.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::{ffi::CStr, fmt};
4
5#[repr(transparent)]
6#[doc(alias = "GstSDPOrigin")]
7pub struct SDPOrigin(pub(crate) crate::ffi::GstSDPOrigin);
8
9unsafe impl Send for SDPOrigin {}
10unsafe impl Sync for SDPOrigin {}
11
12impl SDPOrigin {
13    pub fn username(&self) -> Option<&str> {
14        unsafe {
15            if self.0.username.is_null() {
16                None
17            } else {
18                Some(CStr::from_ptr(self.0.username).to_str().unwrap())
19            }
20        }
21    }
22
23    pub fn sess_id(&self) -> Option<&str> {
24        unsafe {
25            if self.0.sess_id.is_null() {
26                None
27            } else {
28                Some(CStr::from_ptr(self.0.sess_id).to_str().unwrap())
29            }
30        }
31    }
32
33    pub fn sess_version(&self) -> Option<&str> {
34        unsafe {
35            if self.0.sess_version.is_null() {
36                None
37            } else {
38                Some(CStr::from_ptr(self.0.sess_version).to_str().unwrap())
39            }
40        }
41    }
42
43    pub fn nettype(&self) -> Option<&str> {
44        unsafe {
45            if self.0.nettype.is_null() {
46                None
47            } else {
48                Some(CStr::from_ptr(self.0.nettype).to_str().unwrap())
49            }
50        }
51    }
52
53    pub fn addrtype(&self) -> Option<&str> {
54        unsafe {
55            if self.0.addrtype.is_null() {
56                None
57            } else {
58                Some(CStr::from_ptr(self.0.addrtype).to_str().unwrap())
59            }
60        }
61    }
62
63    pub fn addr(&self) -> Option<&str> {
64        unsafe {
65            if self.0.addr.is_null() {
66                None
67            } else {
68                Some(CStr::from_ptr(self.0.addr).to_str().unwrap())
69            }
70        }
71    }
72}
73
74impl fmt::Debug for SDPOrigin {
75    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
76        f.debug_struct("SDPOrigin")
77            .field("username", &self.username())
78            .field("sess_id", &self.sess_id())
79            .field("sess_version", &self.sess_version())
80            .field("nettype", &self.nettype())
81            .field("addrtype", &self.addrtype())
82            .field("addr", &self.addr())
83            .finish()
84    }
85}