screencapturekit/stream/configuration/
internal.rs1use std::ffi::c_void;
2use std::fmt;
3
4#[repr(transparent)]
19pub struct SCStreamConfiguration(pub(crate) *const c_void);
20
21impl PartialEq for SCStreamConfiguration {
22 fn eq(&self, other: &Self) -> bool {
23 self.0 == other.0
24 }
25}
26
27impl Eq for SCStreamConfiguration {}
28
29impl std::hash::Hash for SCStreamConfiguration {
30 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
31 self.0.hash(state);
32 }
33}
34
35impl SCStreamConfiguration {
36 pub(crate) fn internal_init() -> Self {
37 unsafe {
38 let ptr = crate::ffi::sc_stream_configuration_create();
39 Self(ptr)
40 }
41 }
42
43 pub(crate) fn as_ptr(&self) -> *const c_void {
44 self.0
45 }
46}
47
48impl Drop for SCStreamConfiguration {
49 fn drop(&mut self) {
50 if !self.0.is_null() {
51 unsafe {
52 crate::ffi::sc_stream_configuration_release(self.0);
53 }
54 }
55 }
56}
57
58impl Clone for SCStreamConfiguration {
59 fn clone(&self) -> Self {
70 unsafe { Self(crate::ffi::sc_stream_configuration_retain(self.0)) }
71 }
72}
73
74unsafe impl Send for SCStreamConfiguration {}
75unsafe impl Sync for SCStreamConfiguration {}
76
77impl fmt::Debug for SCStreamConfiguration {
78 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79 f.debug_struct("SCStreamConfiguration")
80 .field("ptr", &self.0)
81 .finish()
82 }
83}
84
85impl fmt::Display for SCStreamConfiguration {
86 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87 write!(f, "SCStreamConfiguration")
88 }
89}