objc2_cf_network/generated/
CFNetDiagnostics.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13#[doc(alias = "CFNetDiagnosticRef")]
15#[repr(C)]
16pub struct CFNetDiagnostic {
17 inner: [u8; 0],
18 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22 unsafe impl CFNetDiagnostic {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26 unsafe impl RefEncode<"__CFNetDiagnostic"> for CFNetDiagnostic {}
27);
28
29#[deprecated]
32#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct CFNetDiagnosticStatusValues(pub c_int);
35impl CFNetDiagnosticStatusValues {
36 #[doc(alias = "kCFNetDiagnosticNoErr")]
37 #[deprecated]
38 pub const NoErr: Self = Self(0);
39 #[doc(alias = "kCFNetDiagnosticErr")]
40 #[deprecated]
41 pub const Err: Self = Self(-66560);
42 #[doc(alias = "kCFNetDiagnosticConnectionUp")]
43 #[deprecated]
44 pub const ConnectionUp: Self = Self(-66559);
45 #[doc(alias = "kCFNetDiagnosticConnectionIndeterminate")]
46 #[deprecated]
47 pub const ConnectionIndeterminate: Self = Self(-66558);
48 #[doc(alias = "kCFNetDiagnosticConnectionDown")]
49 #[deprecated]
50 pub const ConnectionDown: Self = Self(-66557);
51}
52
53#[cfg(feature = "objc2")]
54unsafe impl Encode for CFNetDiagnosticStatusValues {
55 const ENCODING: Encoding = c_int::ENCODING;
56}
57
58#[cfg(feature = "objc2")]
59unsafe impl RefEncode for CFNetDiagnosticStatusValues {
60 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63#[deprecated]
65pub type CFNetDiagnosticStatus = CFIndex;
66
67impl CFNetDiagnostic {
68 #[doc(alias = "CFNetDiagnosticCreateWithStreams")]
69 #[deprecated]
70 #[inline]
71 pub unsafe fn with_streams(
72 alloc: Option<&CFAllocator>,
73 read_stream: Option<&CFReadStream>,
74 write_stream: Option<&CFWriteStream>,
75 ) -> CFRetained<CFNetDiagnostic> {
76 extern "C-unwind" {
77 fn CFNetDiagnosticCreateWithStreams(
78 alloc: Option<&CFAllocator>,
79 read_stream: Option<&CFReadStream>,
80 write_stream: Option<&CFWriteStream>,
81 ) -> Option<NonNull<CFNetDiagnostic>>;
82 }
83 let ret = unsafe { CFNetDiagnosticCreateWithStreams(alloc, read_stream, write_stream) };
84 let ret =
85 ret.expect("function was marked as returning non-null, but actually returned NULL");
86 unsafe { CFRetained::from_raw(ret) }
87 }
88
89 #[doc(alias = "CFNetDiagnosticCreateWithURL")]
90 #[deprecated]
91 #[inline]
92 pub unsafe fn with_url(alloc: &CFAllocator, url: &CFURL) -> CFRetained<CFNetDiagnostic> {
93 extern "C-unwind" {
94 fn CFNetDiagnosticCreateWithURL(
95 alloc: &CFAllocator,
96 url: &CFURL,
97 ) -> Option<NonNull<CFNetDiagnostic>>;
98 }
99 let ret = unsafe { CFNetDiagnosticCreateWithURL(alloc, url) };
100 let ret =
101 ret.expect("function was marked as returning non-null, but actually returned NULL");
102 unsafe { CFRetained::from_raw(ret) }
103 }
104
105 #[doc(alias = "CFNetDiagnosticSetName")]
106 #[deprecated]
107 #[inline]
108 pub unsafe fn set_name(&self, name: &CFString) {
109 extern "C-unwind" {
110 fn CFNetDiagnosticSetName(details: &CFNetDiagnostic, name: &CFString);
111 }
112 unsafe { CFNetDiagnosticSetName(self, name) }
113 }
114
115 #[doc(alias = "CFNetDiagnosticDiagnoseProblemInteractively")]
116 #[deprecated]
117 #[inline]
118 pub unsafe fn diagnose_problem_interactively(&self) -> CFNetDiagnosticStatus {
119 extern "C-unwind" {
120 fn CFNetDiagnosticDiagnoseProblemInteractively(
121 details: &CFNetDiagnostic,
122 ) -> CFNetDiagnosticStatus;
123 }
124 unsafe { CFNetDiagnosticDiagnoseProblemInteractively(self) }
125 }
126
127 #[doc(alias = "CFNetDiagnosticCopyNetworkStatusPassively")]
131 #[deprecated]
132 #[inline]
133 pub unsafe fn copy_network_status_passively(
134 &self,
135 description: *mut *const CFString,
136 ) -> CFNetDiagnosticStatus {
137 extern "C-unwind" {
138 fn CFNetDiagnosticCopyNetworkStatusPassively(
139 details: &CFNetDiagnostic,
140 description: *mut *const CFString,
141 ) -> CFNetDiagnosticStatus;
142 }
143 unsafe { CFNetDiagnosticCopyNetworkStatusPassively(self, description) }
144 }
145}
146
147#[deprecated = "renamed to `CFNetDiagnostic::with_streams`"]
148#[inline]
149pub unsafe extern "C-unwind" fn CFNetDiagnosticCreateWithStreams(
150 alloc: Option<&CFAllocator>,
151 read_stream: Option<&CFReadStream>,
152 write_stream: Option<&CFWriteStream>,
153) -> CFRetained<CFNetDiagnostic> {
154 extern "C-unwind" {
155 fn CFNetDiagnosticCreateWithStreams(
156 alloc: Option<&CFAllocator>,
157 read_stream: Option<&CFReadStream>,
158 write_stream: Option<&CFWriteStream>,
159 ) -> Option<NonNull<CFNetDiagnostic>>;
160 }
161 let ret = unsafe { CFNetDiagnosticCreateWithStreams(alloc, read_stream, write_stream) };
162 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
163 unsafe { CFRetained::from_raw(ret) }
164}
165
166#[deprecated = "renamed to `CFNetDiagnostic::with_url`"]
167#[inline]
168pub unsafe extern "C-unwind" fn CFNetDiagnosticCreateWithURL(
169 alloc: &CFAllocator,
170 url: &CFURL,
171) -> CFRetained<CFNetDiagnostic> {
172 extern "C-unwind" {
173 fn CFNetDiagnosticCreateWithURL(
174 alloc: &CFAllocator,
175 url: &CFURL,
176 ) -> Option<NonNull<CFNetDiagnostic>>;
177 }
178 let ret = unsafe { CFNetDiagnosticCreateWithURL(alloc, url) };
179 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
180 unsafe { CFRetained::from_raw(ret) }
181}
182
183extern "C-unwind" {
184 #[deprecated = "renamed to `CFNetDiagnostic::set_name`"]
185 pub fn CFNetDiagnosticSetName(details: &CFNetDiagnostic, name: &CFString);
186}
187
188extern "C-unwind" {
189 #[deprecated = "renamed to `CFNetDiagnostic::diagnose_problem_interactively`"]
190 pub fn CFNetDiagnosticDiagnoseProblemInteractively(
191 details: &CFNetDiagnostic,
192 ) -> CFNetDiagnosticStatus;
193}
194
195extern "C-unwind" {
196 #[deprecated = "renamed to `CFNetDiagnostic::copy_network_status_passively`"]
197 pub fn CFNetDiagnosticCopyNetworkStatusPassively(
198 details: &CFNetDiagnostic,
199 description: *mut *const CFString,
200 ) -> CFNetDiagnosticStatus;
201}