gstreamer_sdp/
sdp_key.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 = "GstSDPKey")]
7pub struct SDPKey(crate::ffi::GstSDPKey);
8
9unsafe impl Send for SDPKey {}
10unsafe impl Sync for SDPKey {}
11
12impl SDPKey {
13    pub fn type_(&self) -> Option<&str> {
14        unsafe {
15            if self.0.type_.is_null() {
16                None
17            } else {
18                Some(CStr::from_ptr(self.0.type_).to_str().unwrap())
19            }
20        }
21    }
22
23    pub fn data(&self) -> Option<&str> {
24        unsafe {
25            if self.0.data.is_null() {
26                None
27            } else {
28                Some(CStr::from_ptr(self.0.data).to_str().unwrap())
29            }
30        }
31    }
32}
33
34impl fmt::Debug for SDPKey {
35    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
36        f.debug_struct("SDPKey")
37            .field("type", &self.type_())
38            .field("data", &self.data())
39            .finish()
40    }
41}