1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11
12use crate::*;
13
14#[repr(C)]
16#[derive(Clone, Copy, Debug, PartialEq)]
17pub struct CFStreamError {
18 pub domain: CFIndex,
19 pub error: i32,
20}
21
22#[cfg(feature = "objc2")]
23unsafe impl Encode for CFStreamError {
24 const ENCODING: Encoding = Encoding::Struct("?", &[<CFIndex>::ENCODING, <i32>::ENCODING]);
25}
26
27#[cfg(feature = "objc2")]
28unsafe impl RefEncode for CFStreamError {
29 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32pub type CFStreamPropertyKey = CFString;
35
36#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct CFStreamStatus(pub CFIndex);
41impl CFStreamStatus {
42 #[doc(alias = "kCFStreamStatusNotOpen")]
43 pub const NotOpen: Self = Self(0);
44 #[doc(alias = "kCFStreamStatusOpening")]
45 pub const Opening: Self = Self(1);
46 #[doc(alias = "kCFStreamStatusOpen")]
47 pub const Open: Self = Self(2);
48 #[doc(alias = "kCFStreamStatusReading")]
49 pub const Reading: Self = Self(3);
50 #[doc(alias = "kCFStreamStatusWriting")]
51 pub const Writing: Self = Self(4);
52 #[doc(alias = "kCFStreamStatusAtEnd")]
53 pub const AtEnd: Self = Self(5);
54 #[doc(alias = "kCFStreamStatusClosed")]
55 pub const Closed: Self = Self(6);
56 #[doc(alias = "kCFStreamStatusError")]
57 pub const Error: Self = Self(7);
58}
59
60#[cfg(feature = "objc2")]
61unsafe impl Encode for CFStreamStatus {
62 const ENCODING: Encoding = CFIndex::ENCODING;
63}
64
65#[cfg(feature = "objc2")]
66unsafe impl RefEncode for CFStreamStatus {
67 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct CFStreamEventType(pub CFOptionFlags);
75bitflags::bitflags! {
76 impl CFStreamEventType: CFOptionFlags {
77 #[doc(alias = "kCFStreamEventNone")]
78 const None = 0;
79 #[doc(alias = "kCFStreamEventOpenCompleted")]
80 const OpenCompleted = 1;
81 #[doc(alias = "kCFStreamEventHasBytesAvailable")]
82 const HasBytesAvailable = 2;
83 #[doc(alias = "kCFStreamEventCanAcceptBytes")]
84 const CanAcceptBytes = 4;
85 #[doc(alias = "kCFStreamEventErrorOccurred")]
86 const ErrorOccurred = 8;
87 #[doc(alias = "kCFStreamEventEndEncountered")]
88 const EndEncountered = 16;
89 }
90}
91
92#[cfg(feature = "objc2")]
93unsafe impl Encode for CFStreamEventType {
94 const ENCODING: Encoding = CFOptionFlags::ENCODING;
95}
96
97#[cfg(feature = "objc2")]
98unsafe impl RefEncode for CFStreamEventType {
99 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
100}
101
102#[repr(C)]
104#[allow(unpredictable_function_pointer_comparisons)]
105#[derive(Clone, Copy, Debug, PartialEq)]
106pub struct CFStreamClientContext {
107 pub version: CFIndex,
108 pub info: *mut c_void,
109 pub retain: Option<unsafe extern "C-unwind" fn(*mut c_void) -> *mut c_void>,
110 pub release: Option<unsafe extern "C-unwind" fn(*mut c_void)>,
111 pub copyDescription: Option<unsafe extern "C-unwind" fn(*mut c_void) -> *const CFString>,
112}
113
114#[cfg(feature = "objc2")]
115unsafe impl Encode for CFStreamClientContext {
116 const ENCODING: Encoding = Encoding::Struct(
117 "?",
118 &[
119 <CFIndex>::ENCODING,
120 <*mut c_void>::ENCODING,
121 <Option<unsafe extern "C-unwind" fn(*mut c_void) -> *mut c_void>>::ENCODING,
122 <Option<unsafe extern "C-unwind" fn(*mut c_void)>>::ENCODING,
123 <Option<unsafe extern "C-unwind" fn(*mut c_void) -> *const CFString>>::ENCODING,
124 ],
125 );
126}
127
128#[cfg(feature = "objc2")]
129unsafe impl RefEncode for CFStreamClientContext {
130 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
131}
132
133#[doc(alias = "CFReadStreamRef")]
137#[repr(C)]
138pub struct CFReadStream {
139 inner: [u8; 0],
140 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
141}
142
143cf_type!(
144 unsafe impl CFReadStream {}
145);
146#[cfg(feature = "objc2")]
147cf_objc2_type!(
148 unsafe impl RefEncode<"__CFReadStream"> for CFReadStream {}
149);
150
151#[doc(alias = "CFWriteStreamRef")]
155#[repr(C)]
156pub struct CFWriteStream {
157 inner: [u8; 0],
158 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
159}
160
161cf_type!(
162 unsafe impl CFWriteStream {}
163);
164#[cfg(feature = "objc2")]
165cf_objc2_type!(
166 unsafe impl RefEncode<"__CFWriteStream"> for CFWriteStream {}
167);
168
169pub type CFReadStreamClientCallBack =
171 Option<unsafe extern "C-unwind" fn(*mut CFReadStream, CFStreamEventType, *mut c_void)>;
172
173pub type CFWriteStreamClientCallBack =
175 Option<unsafe extern "C-unwind" fn(*mut CFWriteStream, CFStreamEventType, *mut c_void)>;
176
177unsafe impl ConcreteType for CFReadStream {
178 #[doc(alias = "CFReadStreamGetTypeID")]
179 #[inline]
180 fn type_id() -> CFTypeID {
181 extern "C-unwind" {
182 fn CFReadStreamGetTypeID() -> CFTypeID;
183 }
184 unsafe { CFReadStreamGetTypeID() }
185 }
186}
187
188unsafe impl ConcreteType for CFWriteStream {
189 #[doc(alias = "CFWriteStreamGetTypeID")]
190 #[inline]
191 fn type_id() -> CFTypeID {
192 extern "C-unwind" {
193 fn CFWriteStreamGetTypeID() -> CFTypeID;
194 }
195 unsafe { CFWriteStreamGetTypeID() }
196 }
197}
198
199extern "C" {
200 pub static kCFStreamPropertyDataWritten: Option<&'static CFStreamPropertyKey>;
202}
203
204impl CFReadStream {
205 #[doc(alias = "CFReadStreamCreateWithBytesNoCopy")]
211 #[inline]
212 pub unsafe fn with_bytes_no_copy(
213 alloc: Option<&CFAllocator>,
214 bytes: *const u8,
215 length: CFIndex,
216 bytes_deallocator: Option<&CFAllocator>,
217 ) -> Option<CFRetained<CFReadStream>> {
218 extern "C-unwind" {
219 fn CFReadStreamCreateWithBytesNoCopy(
220 alloc: Option<&CFAllocator>,
221 bytes: *const u8,
222 length: CFIndex,
223 bytes_deallocator: Option<&CFAllocator>,
224 ) -> Option<NonNull<CFReadStream>>;
225 }
226 let ret =
227 unsafe { CFReadStreamCreateWithBytesNoCopy(alloc, bytes, length, bytes_deallocator) };
228 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
229 }
230}
231
232impl CFWriteStream {
233 #[doc(alias = "CFWriteStreamCreateWithBuffer")]
238 #[inline]
239 pub unsafe fn with_buffer(
240 alloc: Option<&CFAllocator>,
241 buffer: *mut u8,
242 buffer_capacity: CFIndex,
243 ) -> Option<CFRetained<CFWriteStream>> {
244 extern "C-unwind" {
245 fn CFWriteStreamCreateWithBuffer(
246 alloc: Option<&CFAllocator>,
247 buffer: *mut u8,
248 buffer_capacity: CFIndex,
249 ) -> Option<NonNull<CFWriteStream>>;
250 }
251 let ret = unsafe { CFWriteStreamCreateWithBuffer(alloc, buffer, buffer_capacity) };
252 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
253 }
254
255 #[doc(alias = "CFWriteStreamCreateWithAllocatedBuffers")]
256 #[inline]
257 pub fn with_allocated_buffers(
258 alloc: Option<&CFAllocator>,
259 buffer_allocator: Option<&CFAllocator>,
260 ) -> Option<CFRetained<CFWriteStream>> {
261 extern "C-unwind" {
262 fn CFWriteStreamCreateWithAllocatedBuffers(
263 alloc: Option<&CFAllocator>,
264 buffer_allocator: Option<&CFAllocator>,
265 ) -> Option<NonNull<CFWriteStream>>;
266 }
267 let ret = unsafe { CFWriteStreamCreateWithAllocatedBuffers(alloc, buffer_allocator) };
268 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
269 }
270}
271
272impl CFReadStream {
273 #[doc(alias = "CFReadStreamCreateWithFile")]
274 #[cfg(feature = "CFURL")]
275 #[inline]
276 pub fn with_file(
277 alloc: Option<&CFAllocator>,
278 file_url: Option<&CFURL>,
279 ) -> Option<CFRetained<CFReadStream>> {
280 extern "C-unwind" {
281 fn CFReadStreamCreateWithFile(
282 alloc: Option<&CFAllocator>,
283 file_url: Option<&CFURL>,
284 ) -> Option<NonNull<CFReadStream>>;
285 }
286 let ret = unsafe { CFReadStreamCreateWithFile(alloc, file_url) };
287 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
288 }
289}
290
291impl CFWriteStream {
292 #[doc(alias = "CFWriteStreamCreateWithFile")]
293 #[cfg(feature = "CFURL")]
294 #[inline]
295 pub fn with_file(
296 alloc: Option<&CFAllocator>,
297 file_url: Option<&CFURL>,
298 ) -> Option<CFRetained<CFWriteStream>> {
299 extern "C-unwind" {
300 fn CFWriteStreamCreateWithFile(
301 alloc: Option<&CFAllocator>,
302 file_url: Option<&CFURL>,
303 ) -> Option<NonNull<CFWriteStream>>;
304 }
305 let ret = unsafe { CFWriteStreamCreateWithFile(alloc, file_url) };
306 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
307 }
308}
309
310extern "C-unwind" {
311 pub fn CFStreamCreateBoundPair(
317 alloc: Option<&CFAllocator>,
318 read_stream: *mut *mut CFReadStream,
319 write_stream: *mut *mut CFWriteStream,
320 transfer_buffer_size: CFIndex,
321 );
322}
323
324extern "C" {
325 pub static kCFStreamPropertyAppendToFile: Option<&'static CFStreamPropertyKey>;
327}
328
329extern "C" {
330 pub static kCFStreamPropertyFileCurrentOffset: Option<&'static CFStreamPropertyKey>;
332}
333
334extern "C" {
335 pub static kCFStreamPropertySocketNativeHandle: Option<&'static CFStreamPropertyKey>;
337}
338
339extern "C" {
340 pub static kCFStreamPropertySocketRemoteHostName: Option<&'static CFStreamPropertyKey>;
342}
343
344extern "C" {
345 pub static kCFStreamPropertySocketRemotePortNumber: Option<&'static CFStreamPropertyKey>;
347}
348
349extern "C" {
350 pub static kCFStreamErrorDomainSOCKS: c_int;
352}
353
354extern "C" {
355 pub static kCFStreamPropertySOCKSProxy: &'static CFString;
357}
358
359extern "C" {
360 pub static kCFStreamPropertySOCKSProxyHost: &'static CFString;
362}
363
364extern "C" {
365 pub static kCFStreamPropertySOCKSProxyPort: &'static CFString;
367}
368
369extern "C" {
370 pub static kCFStreamPropertySOCKSVersion: &'static CFString;
372}
373
374extern "C" {
375 pub static kCFStreamSocketSOCKSVersion4: &'static CFString;
377}
378
379extern "C" {
380 pub static kCFStreamSocketSOCKSVersion5: &'static CFString;
382}
383
384extern "C" {
385 pub static kCFStreamPropertySOCKSUser: &'static CFString;
387}
388
389extern "C" {
390 pub static kCFStreamPropertySOCKSPassword: &'static CFString;
392}
393
394extern "C" {
395 pub static kCFStreamErrorDomainSSL: c_int;
397}
398
399extern "C" {
400 pub static kCFStreamPropertySocketSecurityLevel: &'static CFString;
402}
403
404extern "C" {
405 pub static kCFStreamSocketSecurityLevelNone: &'static CFString;
407}
408
409extern "C" {
410 #[deprecated]
412 pub static kCFStreamSocketSecurityLevelSSLv2: &'static CFString;
413}
414
415extern "C" {
416 #[deprecated]
418 pub static kCFStreamSocketSecurityLevelSSLv3: &'static CFString;
419}
420
421extern "C" {
422 pub static kCFStreamSocketSecurityLevelTLSv1: &'static CFString;
424}
425
426extern "C" {
427 pub static kCFStreamSocketSecurityLevelNegotiatedSSL: &'static CFString;
429}
430
431extern "C" {
432 pub static kCFStreamPropertyShouldCloseNativeSocket: &'static CFString;
434}
435
436extern "C-unwind" {
437 #[cfg(feature = "CFSocket")]
443 #[deprecated = "Use nw_connection_t in Network framework instead"]
444 pub fn CFStreamCreatePairWithSocket(
445 alloc: Option<&CFAllocator>,
446 sock: CFSocketNativeHandle,
447 read_stream: *mut *mut CFReadStream,
448 write_stream: *mut *mut CFWriteStream,
449 );
450}
451
452extern "C-unwind" {
453 #[deprecated = "Use nw_connection_t in Network framework instead"]
460 pub fn CFStreamCreatePairWithSocketToHost(
461 alloc: Option<&CFAllocator>,
462 host: Option<&CFString>,
463 port: u32,
464 read_stream: *mut *mut CFReadStream,
465 write_stream: *mut *mut CFWriteStream,
466 );
467}
468
469extern "C-unwind" {
470 #[cfg(all(feature = "CFData", feature = "CFSocket"))]
477 #[deprecated = "Use nw_connection_t in Network framework instead"]
478 pub fn CFStreamCreatePairWithPeerSocketSignature(
479 alloc: Option<&CFAllocator>,
480 signature: *const CFSocketSignature,
481 read_stream: *mut *mut CFReadStream,
482 write_stream: *mut *mut CFWriteStream,
483 );
484}
485
486impl CFReadStream {
487 #[doc(alias = "CFReadStreamGetStatus")]
488 #[inline]
489 pub fn status(&self) -> CFStreamStatus {
490 extern "C-unwind" {
491 fn CFReadStreamGetStatus(stream: &CFReadStream) -> CFStreamStatus;
492 }
493 unsafe { CFReadStreamGetStatus(self) }
494 }
495}
496
497impl CFWriteStream {
498 #[doc(alias = "CFWriteStreamGetStatus")]
499 #[inline]
500 pub fn status(&self) -> CFStreamStatus {
501 extern "C-unwind" {
502 fn CFWriteStreamGetStatus(stream: &CFWriteStream) -> CFStreamStatus;
503 }
504 unsafe { CFWriteStreamGetStatus(self) }
505 }
506}
507
508impl CFReadStream {
509 #[doc(alias = "CFReadStreamCopyError")]
510 #[cfg(feature = "CFError")]
511 #[inline]
512 pub fn copy_error(&self) -> Option<CFRetained<CFError>> {
513 extern "C-unwind" {
514 fn CFReadStreamCopyError(stream: &CFReadStream) -> Option<NonNull<CFError>>;
515 }
516 let ret = unsafe { CFReadStreamCopyError(self) };
517 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
518 }
519}
520
521impl CFWriteStream {
522 #[doc(alias = "CFWriteStreamCopyError")]
523 #[cfg(feature = "CFError")]
524 #[inline]
525 pub fn copy_error(&self) -> Option<CFRetained<CFError>> {
526 extern "C-unwind" {
527 fn CFWriteStreamCopyError(stream: &CFWriteStream) -> Option<NonNull<CFError>>;
528 }
529 let ret = unsafe { CFWriteStreamCopyError(self) };
530 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
531 }
532}
533
534impl CFReadStream {
535 #[doc(alias = "CFReadStreamOpen")]
536 #[inline]
537 pub fn open(&self) -> bool {
538 extern "C-unwind" {
539 fn CFReadStreamOpen(stream: &CFReadStream) -> Boolean;
540 }
541 let ret = unsafe { CFReadStreamOpen(self) };
542 ret != 0
543 }
544}
545
546impl CFWriteStream {
547 #[doc(alias = "CFWriteStreamOpen")]
548 #[inline]
549 pub fn open(&self) -> bool {
550 extern "C-unwind" {
551 fn CFWriteStreamOpen(stream: &CFWriteStream) -> Boolean;
552 }
553 let ret = unsafe { CFWriteStreamOpen(self) };
554 ret != 0
555 }
556}
557
558impl CFReadStream {
559 #[doc(alias = "CFReadStreamClose")]
560 #[inline]
561 pub fn close(&self) {
562 extern "C-unwind" {
563 fn CFReadStreamClose(stream: &CFReadStream);
564 }
565 unsafe { CFReadStreamClose(self) }
566 }
567}
568
569impl CFWriteStream {
570 #[doc(alias = "CFWriteStreamClose")]
571 #[inline]
572 pub fn close(&self) {
573 extern "C-unwind" {
574 fn CFWriteStreamClose(stream: &CFWriteStream);
575 }
576 unsafe { CFWriteStreamClose(self) }
577 }
578}
579
580impl CFReadStream {
581 #[doc(alias = "CFReadStreamHasBytesAvailable")]
582 #[inline]
583 pub fn has_bytes_available(&self) -> bool {
584 extern "C-unwind" {
585 fn CFReadStreamHasBytesAvailable(stream: &CFReadStream) -> Boolean;
586 }
587 let ret = unsafe { CFReadStreamHasBytesAvailable(self) };
588 ret != 0
589 }
590
591 #[doc(alias = "CFReadStreamRead")]
595 #[inline]
596 pub unsafe fn read(&self, buffer: *mut u8, buffer_length: CFIndex) -> CFIndex {
597 extern "C-unwind" {
598 fn CFReadStreamRead(
599 stream: &CFReadStream,
600 buffer: *mut u8,
601 buffer_length: CFIndex,
602 ) -> CFIndex;
603 }
604 unsafe { CFReadStreamRead(self, buffer, buffer_length) }
605 }
606
607 #[doc(alias = "CFReadStreamGetBuffer")]
611 #[inline]
612 pub unsafe fn buffer(
613 &self,
614 max_bytes_to_read: CFIndex,
615 num_bytes_read: *mut CFIndex,
616 ) -> *const u8 {
617 extern "C-unwind" {
618 fn CFReadStreamGetBuffer(
619 stream: &CFReadStream,
620 max_bytes_to_read: CFIndex,
621 num_bytes_read: *mut CFIndex,
622 ) -> *const u8;
623 }
624 unsafe { CFReadStreamGetBuffer(self, max_bytes_to_read, num_bytes_read) }
625 }
626}
627
628impl CFWriteStream {
629 #[doc(alias = "CFWriteStreamCanAcceptBytes")]
630 #[inline]
631 pub fn can_accept_bytes(&self) -> bool {
632 extern "C-unwind" {
633 fn CFWriteStreamCanAcceptBytes(stream: &CFWriteStream) -> Boolean;
634 }
635 let ret = unsafe { CFWriteStreamCanAcceptBytes(self) };
636 ret != 0
637 }
638
639 #[doc(alias = "CFWriteStreamWrite")]
643 #[inline]
644 pub unsafe fn write(&self, buffer: *const u8, buffer_length: CFIndex) -> CFIndex {
645 extern "C-unwind" {
646 fn CFWriteStreamWrite(
647 stream: &CFWriteStream,
648 buffer: *const u8,
649 buffer_length: CFIndex,
650 ) -> CFIndex;
651 }
652 unsafe { CFWriteStreamWrite(self, buffer, buffer_length) }
653 }
654}
655
656impl CFReadStream {
657 #[doc(alias = "CFReadStreamCopyProperty")]
658 #[inline]
659 pub fn property(
660 &self,
661 property_name: Option<&CFStreamPropertyKey>,
662 ) -> Option<CFRetained<CFType>> {
663 extern "C-unwind" {
664 fn CFReadStreamCopyProperty(
665 stream: &CFReadStream,
666 property_name: Option<&CFStreamPropertyKey>,
667 ) -> Option<NonNull<CFType>>;
668 }
669 let ret = unsafe { CFReadStreamCopyProperty(self, property_name) };
670 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
671 }
672}
673
674impl CFWriteStream {
675 #[doc(alias = "CFWriteStreamCopyProperty")]
676 #[inline]
677 pub fn property(
678 &self,
679 property_name: Option<&CFStreamPropertyKey>,
680 ) -> Option<CFRetained<CFType>> {
681 extern "C-unwind" {
682 fn CFWriteStreamCopyProperty(
683 stream: &CFWriteStream,
684 property_name: Option<&CFStreamPropertyKey>,
685 ) -> Option<NonNull<CFType>>;
686 }
687 let ret = unsafe { CFWriteStreamCopyProperty(self, property_name) };
688 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
689 }
690}
691
692impl CFReadStream {
693 #[doc(alias = "CFReadStreamSetProperty")]
699 #[inline]
700 pub unsafe fn set_property(
701 &self,
702 property_name: Option<&CFStreamPropertyKey>,
703 property_value: Option<&CFType>,
704 ) -> bool {
705 extern "C-unwind" {
706 fn CFReadStreamSetProperty(
707 stream: &CFReadStream,
708 property_name: Option<&CFStreamPropertyKey>,
709 property_value: Option<&CFType>,
710 ) -> Boolean;
711 }
712 let ret = unsafe { CFReadStreamSetProperty(self, property_name, property_value) };
713 ret != 0
714 }
715}
716
717impl CFWriteStream {
718 #[doc(alias = "CFWriteStreamSetProperty")]
724 #[inline]
725 pub unsafe fn set_property(
726 &self,
727 property_name: Option<&CFStreamPropertyKey>,
728 property_value: Option<&CFType>,
729 ) -> bool {
730 extern "C-unwind" {
731 fn CFWriteStreamSetProperty(
732 stream: &CFWriteStream,
733 property_name: Option<&CFStreamPropertyKey>,
734 property_value: Option<&CFType>,
735 ) -> Boolean;
736 }
737 let ret = unsafe { CFWriteStreamSetProperty(self, property_name, property_value) };
738 ret != 0
739 }
740}
741
742impl CFReadStream {
743 #[doc(alias = "CFReadStreamSetClient")]
748 #[inline]
749 pub unsafe fn set_client(
750 &self,
751 stream_events: CFOptionFlags,
752 client_cb: CFReadStreamClientCallBack,
753 client_context: *mut CFStreamClientContext,
754 ) -> bool {
755 extern "C-unwind" {
756 fn CFReadStreamSetClient(
757 stream: &CFReadStream,
758 stream_events: CFOptionFlags,
759 client_cb: CFReadStreamClientCallBack,
760 client_context: *mut CFStreamClientContext,
761 ) -> Boolean;
762 }
763 let ret = unsafe { CFReadStreamSetClient(self, stream_events, client_cb, client_context) };
764 ret != 0
765 }
766}
767
768impl CFWriteStream {
769 #[doc(alias = "CFWriteStreamSetClient")]
774 #[inline]
775 pub unsafe fn set_client(
776 &self,
777 stream_events: CFOptionFlags,
778 client_cb: CFWriteStreamClientCallBack,
779 client_context: *mut CFStreamClientContext,
780 ) -> bool {
781 extern "C-unwind" {
782 fn CFWriteStreamSetClient(
783 stream: &CFWriteStream,
784 stream_events: CFOptionFlags,
785 client_cb: CFWriteStreamClientCallBack,
786 client_context: *mut CFStreamClientContext,
787 ) -> Boolean;
788 }
789 let ret = unsafe { CFWriteStreamSetClient(self, stream_events, client_cb, client_context) };
790 ret != 0
791 }
792}
793
794impl CFReadStream {
795 #[doc(alias = "CFReadStreamScheduleWithRunLoop")]
796 #[cfg(feature = "CFRunLoop")]
797 #[inline]
798 pub fn schedule_with_run_loop(
799 &self,
800 run_loop: Option<&CFRunLoop>,
801 run_loop_mode: Option<&CFRunLoopMode>,
802 ) {
803 extern "C-unwind" {
804 fn CFReadStreamScheduleWithRunLoop(
805 stream: &CFReadStream,
806 run_loop: Option<&CFRunLoop>,
807 run_loop_mode: Option<&CFRunLoopMode>,
808 );
809 }
810 unsafe { CFReadStreamScheduleWithRunLoop(self, run_loop, run_loop_mode) }
811 }
812}
813
814impl CFWriteStream {
815 #[doc(alias = "CFWriteStreamScheduleWithRunLoop")]
816 #[cfg(feature = "CFRunLoop")]
817 #[inline]
818 pub fn schedule_with_run_loop(
819 &self,
820 run_loop: Option<&CFRunLoop>,
821 run_loop_mode: Option<&CFRunLoopMode>,
822 ) {
823 extern "C-unwind" {
824 fn CFWriteStreamScheduleWithRunLoop(
825 stream: &CFWriteStream,
826 run_loop: Option<&CFRunLoop>,
827 run_loop_mode: Option<&CFRunLoopMode>,
828 );
829 }
830 unsafe { CFWriteStreamScheduleWithRunLoop(self, run_loop, run_loop_mode) }
831 }
832}
833
834impl CFReadStream {
835 #[doc(alias = "CFReadStreamUnscheduleFromRunLoop")]
836 #[cfg(feature = "CFRunLoop")]
837 #[inline]
838 pub fn unschedule_from_run_loop(
839 &self,
840 run_loop: Option<&CFRunLoop>,
841 run_loop_mode: Option<&CFRunLoopMode>,
842 ) {
843 extern "C-unwind" {
844 fn CFReadStreamUnscheduleFromRunLoop(
845 stream: &CFReadStream,
846 run_loop: Option<&CFRunLoop>,
847 run_loop_mode: Option<&CFRunLoopMode>,
848 );
849 }
850 unsafe { CFReadStreamUnscheduleFromRunLoop(self, run_loop, run_loop_mode) }
851 }
852}
853
854impl CFWriteStream {
855 #[doc(alias = "CFWriteStreamUnscheduleFromRunLoop")]
856 #[cfg(feature = "CFRunLoop")]
857 #[inline]
858 pub fn unschedule_from_run_loop(
859 &self,
860 run_loop: Option<&CFRunLoop>,
861 run_loop_mode: Option<&CFRunLoopMode>,
862 ) {
863 extern "C-unwind" {
864 fn CFWriteStreamUnscheduleFromRunLoop(
865 stream: &CFWriteStream,
866 run_loop: Option<&CFRunLoop>,
867 run_loop_mode: Option<&CFRunLoopMode>,
868 );
869 }
870 unsafe { CFWriteStreamUnscheduleFromRunLoop(self, run_loop, run_loop_mode) }
871 }
872}
873
874impl CFReadStream {
875 #[doc(alias = "CFReadStreamSetDispatchQueue")]
880 #[cfg(feature = "dispatch2")]
881 #[inline]
882 pub unsafe fn set_dispatch_queue(&self, q: Option<&DispatchQueue>) {
883 extern "C-unwind" {
884 fn CFReadStreamSetDispatchQueue(stream: &CFReadStream, q: Option<&DispatchQueue>);
885 }
886 unsafe { CFReadStreamSetDispatchQueue(self, q) }
887 }
888}
889
890impl CFWriteStream {
891 #[doc(alias = "CFWriteStreamSetDispatchQueue")]
896 #[cfg(feature = "dispatch2")]
897 #[inline]
898 pub unsafe fn set_dispatch_queue(&self, q: Option<&DispatchQueue>) {
899 extern "C-unwind" {
900 fn CFWriteStreamSetDispatchQueue(stream: &CFWriteStream, q: Option<&DispatchQueue>);
901 }
902 unsafe { CFWriteStreamSetDispatchQueue(self, q) }
903 }
904}
905
906impl CFReadStream {
907 #[doc(alias = "CFReadStreamCopyDispatchQueue")]
908 #[cfg(feature = "dispatch2")]
909 #[inline]
910 pub fn dispatch_queue(&self) -> Option<DispatchRetained<DispatchQueue>> {
911 extern "C-unwind" {
912 fn CFReadStreamCopyDispatchQueue(
913 stream: &CFReadStream,
914 ) -> Option<NonNull<DispatchQueue>>;
915 }
916 let ret = unsafe { CFReadStreamCopyDispatchQueue(self) };
917 ret.map(|ret| unsafe { DispatchRetained::from_raw(ret) })
918 }
919}
920
921impl CFWriteStream {
922 #[doc(alias = "CFWriteStreamCopyDispatchQueue")]
923 #[cfg(feature = "dispatch2")]
924 #[inline]
925 pub fn dispatch_queue(&self) -> Option<DispatchRetained<DispatchQueue>> {
926 extern "C-unwind" {
927 fn CFWriteStreamCopyDispatchQueue(
928 stream: &CFWriteStream,
929 ) -> Option<NonNull<DispatchQueue>>;
930 }
931 let ret = unsafe { CFWriteStreamCopyDispatchQueue(self) };
932 ret.map(|ret| unsafe { DispatchRetained::from_raw(ret) })
933 }
934}
935
936#[repr(transparent)]
939#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
940pub struct CFStreamErrorDomain(pub CFIndex);
941impl CFStreamErrorDomain {
942 #[doc(alias = "kCFStreamErrorDomainCustom")]
943 pub const Custom: Self = Self(-1);
944 #[doc(alias = "kCFStreamErrorDomainPOSIX")]
945 pub const POSIX: Self = Self(1);
946 #[doc(alias = "kCFStreamErrorDomainMacOSStatus")]
947 pub const MacOSStatus: Self = Self(2);
948}
949
950#[cfg(feature = "objc2")]
951unsafe impl Encode for CFStreamErrorDomain {
952 const ENCODING: Encoding = CFIndex::ENCODING;
953}
954
955#[cfg(feature = "objc2")]
956unsafe impl RefEncode for CFStreamErrorDomain {
957 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
958}
959
960impl CFReadStream {
961 #[doc(alias = "CFReadStreamGetError")]
962 #[inline]
963 pub fn error(&self) -> CFStreamError {
964 extern "C-unwind" {
965 fn CFReadStreamGetError(stream: &CFReadStream) -> CFStreamError;
966 }
967 unsafe { CFReadStreamGetError(self) }
968 }
969}
970
971impl CFWriteStream {
972 #[doc(alias = "CFWriteStreamGetError")]
973 #[inline]
974 pub fn error(&self) -> CFStreamError {
975 extern "C-unwind" {
976 fn CFWriteStreamGetError(stream: &CFWriteStream) -> CFStreamError;
977 }
978 unsafe { CFWriteStreamGetError(self) }
979 }
980}
981
982#[deprecated = "renamed to `CFReadStream::with_bytes_no_copy`"]
983#[inline]
984pub unsafe extern "C-unwind" fn CFReadStreamCreateWithBytesNoCopy(
985 alloc: Option<&CFAllocator>,
986 bytes: *const u8,
987 length: CFIndex,
988 bytes_deallocator: Option<&CFAllocator>,
989) -> Option<CFRetained<CFReadStream>> {
990 extern "C-unwind" {
991 fn CFReadStreamCreateWithBytesNoCopy(
992 alloc: Option<&CFAllocator>,
993 bytes: *const u8,
994 length: CFIndex,
995 bytes_deallocator: Option<&CFAllocator>,
996 ) -> Option<NonNull<CFReadStream>>;
997 }
998 let ret = unsafe { CFReadStreamCreateWithBytesNoCopy(alloc, bytes, length, bytes_deallocator) };
999 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1000}
1001
1002#[deprecated = "renamed to `CFWriteStream::with_buffer`"]
1003#[inline]
1004pub unsafe extern "C-unwind" fn CFWriteStreamCreateWithBuffer(
1005 alloc: Option<&CFAllocator>,
1006 buffer: *mut u8,
1007 buffer_capacity: CFIndex,
1008) -> Option<CFRetained<CFWriteStream>> {
1009 extern "C-unwind" {
1010 fn CFWriteStreamCreateWithBuffer(
1011 alloc: Option<&CFAllocator>,
1012 buffer: *mut u8,
1013 buffer_capacity: CFIndex,
1014 ) -> Option<NonNull<CFWriteStream>>;
1015 }
1016 let ret = unsafe { CFWriteStreamCreateWithBuffer(alloc, buffer, buffer_capacity) };
1017 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1018}
1019
1020#[deprecated = "renamed to `CFWriteStream::with_allocated_buffers`"]
1021#[inline]
1022pub extern "C-unwind" fn CFWriteStreamCreateWithAllocatedBuffers(
1023 alloc: Option<&CFAllocator>,
1024 buffer_allocator: Option<&CFAllocator>,
1025) -> Option<CFRetained<CFWriteStream>> {
1026 extern "C-unwind" {
1027 fn CFWriteStreamCreateWithAllocatedBuffers(
1028 alloc: Option<&CFAllocator>,
1029 buffer_allocator: Option<&CFAllocator>,
1030 ) -> Option<NonNull<CFWriteStream>>;
1031 }
1032 let ret = unsafe { CFWriteStreamCreateWithAllocatedBuffers(alloc, buffer_allocator) };
1033 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1034}
1035
1036#[cfg(feature = "CFURL")]
1037#[deprecated = "renamed to `CFReadStream::with_file`"]
1038#[inline]
1039pub extern "C-unwind" fn CFReadStreamCreateWithFile(
1040 alloc: Option<&CFAllocator>,
1041 file_url: Option<&CFURL>,
1042) -> Option<CFRetained<CFReadStream>> {
1043 extern "C-unwind" {
1044 fn CFReadStreamCreateWithFile(
1045 alloc: Option<&CFAllocator>,
1046 file_url: Option<&CFURL>,
1047 ) -> Option<NonNull<CFReadStream>>;
1048 }
1049 let ret = unsafe { CFReadStreamCreateWithFile(alloc, file_url) };
1050 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1051}
1052
1053#[cfg(feature = "CFURL")]
1054#[deprecated = "renamed to `CFWriteStream::with_file`"]
1055#[inline]
1056pub extern "C-unwind" fn CFWriteStreamCreateWithFile(
1057 alloc: Option<&CFAllocator>,
1058 file_url: Option<&CFURL>,
1059) -> Option<CFRetained<CFWriteStream>> {
1060 extern "C-unwind" {
1061 fn CFWriteStreamCreateWithFile(
1062 alloc: Option<&CFAllocator>,
1063 file_url: Option<&CFURL>,
1064 ) -> Option<NonNull<CFWriteStream>>;
1065 }
1066 let ret = unsafe { CFWriteStreamCreateWithFile(alloc, file_url) };
1067 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1068}
1069
1070#[deprecated = "renamed to `CFReadStream::status`"]
1071#[inline]
1072pub extern "C-unwind" fn CFReadStreamGetStatus(stream: &CFReadStream) -> CFStreamStatus {
1073 extern "C-unwind" {
1074 fn CFReadStreamGetStatus(stream: &CFReadStream) -> CFStreamStatus;
1075 }
1076 unsafe { CFReadStreamGetStatus(stream) }
1077}
1078
1079#[deprecated = "renamed to `CFWriteStream::status`"]
1080#[inline]
1081pub extern "C-unwind" fn CFWriteStreamGetStatus(stream: &CFWriteStream) -> CFStreamStatus {
1082 extern "C-unwind" {
1083 fn CFWriteStreamGetStatus(stream: &CFWriteStream) -> CFStreamStatus;
1084 }
1085 unsafe { CFWriteStreamGetStatus(stream) }
1086}
1087
1088#[cfg(feature = "CFError")]
1089#[deprecated = "renamed to `CFReadStream::copy_error`"]
1090#[inline]
1091pub extern "C-unwind" fn CFReadStreamCopyError(
1092 stream: &CFReadStream,
1093) -> Option<CFRetained<CFError>> {
1094 extern "C-unwind" {
1095 fn CFReadStreamCopyError(stream: &CFReadStream) -> Option<NonNull<CFError>>;
1096 }
1097 let ret = unsafe { CFReadStreamCopyError(stream) };
1098 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1099}
1100
1101#[cfg(feature = "CFError")]
1102#[deprecated = "renamed to `CFWriteStream::copy_error`"]
1103#[inline]
1104pub extern "C-unwind" fn CFWriteStreamCopyError(
1105 stream: &CFWriteStream,
1106) -> Option<CFRetained<CFError>> {
1107 extern "C-unwind" {
1108 fn CFWriteStreamCopyError(stream: &CFWriteStream) -> Option<NonNull<CFError>>;
1109 }
1110 let ret = unsafe { CFWriteStreamCopyError(stream) };
1111 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1112}
1113
1114#[deprecated = "renamed to `CFReadStream::open`"]
1115#[inline]
1116pub extern "C-unwind" fn CFReadStreamOpen(stream: &CFReadStream) -> bool {
1117 extern "C-unwind" {
1118 fn CFReadStreamOpen(stream: &CFReadStream) -> Boolean;
1119 }
1120 let ret = unsafe { CFReadStreamOpen(stream) };
1121 ret != 0
1122}
1123
1124#[deprecated = "renamed to `CFWriteStream::open`"]
1125#[inline]
1126pub extern "C-unwind" fn CFWriteStreamOpen(stream: &CFWriteStream) -> bool {
1127 extern "C-unwind" {
1128 fn CFWriteStreamOpen(stream: &CFWriteStream) -> Boolean;
1129 }
1130 let ret = unsafe { CFWriteStreamOpen(stream) };
1131 ret != 0
1132}
1133
1134#[deprecated = "renamed to `CFReadStream::close`"]
1135#[inline]
1136pub extern "C-unwind" fn CFReadStreamClose(stream: &CFReadStream) {
1137 extern "C-unwind" {
1138 fn CFReadStreamClose(stream: &CFReadStream);
1139 }
1140 unsafe { CFReadStreamClose(stream) }
1141}
1142
1143#[deprecated = "renamed to `CFWriteStream::close`"]
1144#[inline]
1145pub extern "C-unwind" fn CFWriteStreamClose(stream: &CFWriteStream) {
1146 extern "C-unwind" {
1147 fn CFWriteStreamClose(stream: &CFWriteStream);
1148 }
1149 unsafe { CFWriteStreamClose(stream) }
1150}
1151
1152#[deprecated = "renamed to `CFReadStream::has_bytes_available`"]
1153#[inline]
1154pub extern "C-unwind" fn CFReadStreamHasBytesAvailable(stream: &CFReadStream) -> bool {
1155 extern "C-unwind" {
1156 fn CFReadStreamHasBytesAvailable(stream: &CFReadStream) -> Boolean;
1157 }
1158 let ret = unsafe { CFReadStreamHasBytesAvailable(stream) };
1159 ret != 0
1160}
1161
1162extern "C-unwind" {
1163 #[deprecated = "renamed to `CFReadStream::read`"]
1164 pub fn CFReadStreamRead(
1165 stream: &CFReadStream,
1166 buffer: *mut u8,
1167 buffer_length: CFIndex,
1168 ) -> CFIndex;
1169}
1170
1171extern "C-unwind" {
1172 #[deprecated = "renamed to `CFReadStream::buffer`"]
1173 pub fn CFReadStreamGetBuffer(
1174 stream: &CFReadStream,
1175 max_bytes_to_read: CFIndex,
1176 num_bytes_read: *mut CFIndex,
1177 ) -> *const u8;
1178}
1179
1180#[deprecated = "renamed to `CFWriteStream::can_accept_bytes`"]
1181#[inline]
1182pub extern "C-unwind" fn CFWriteStreamCanAcceptBytes(stream: &CFWriteStream) -> bool {
1183 extern "C-unwind" {
1184 fn CFWriteStreamCanAcceptBytes(stream: &CFWriteStream) -> Boolean;
1185 }
1186 let ret = unsafe { CFWriteStreamCanAcceptBytes(stream) };
1187 ret != 0
1188}
1189
1190extern "C-unwind" {
1191 #[deprecated = "renamed to `CFWriteStream::write`"]
1192 pub fn CFWriteStreamWrite(
1193 stream: &CFWriteStream,
1194 buffer: *const u8,
1195 buffer_length: CFIndex,
1196 ) -> CFIndex;
1197}
1198
1199#[deprecated = "renamed to `CFReadStream::property`"]
1200#[inline]
1201pub extern "C-unwind" fn CFReadStreamCopyProperty(
1202 stream: &CFReadStream,
1203 property_name: Option<&CFStreamPropertyKey>,
1204) -> Option<CFRetained<CFType>> {
1205 extern "C-unwind" {
1206 fn CFReadStreamCopyProperty(
1207 stream: &CFReadStream,
1208 property_name: Option<&CFStreamPropertyKey>,
1209 ) -> Option<NonNull<CFType>>;
1210 }
1211 let ret = unsafe { CFReadStreamCopyProperty(stream, property_name) };
1212 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1213}
1214
1215#[deprecated = "renamed to `CFWriteStream::property`"]
1216#[inline]
1217pub extern "C-unwind" fn CFWriteStreamCopyProperty(
1218 stream: &CFWriteStream,
1219 property_name: Option<&CFStreamPropertyKey>,
1220) -> Option<CFRetained<CFType>> {
1221 extern "C-unwind" {
1222 fn CFWriteStreamCopyProperty(
1223 stream: &CFWriteStream,
1224 property_name: Option<&CFStreamPropertyKey>,
1225 ) -> Option<NonNull<CFType>>;
1226 }
1227 let ret = unsafe { CFWriteStreamCopyProperty(stream, property_name) };
1228 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1229}
1230
1231#[deprecated = "renamed to `CFReadStream::set_property`"]
1232#[inline]
1233pub unsafe extern "C-unwind" fn CFReadStreamSetProperty(
1234 stream: &CFReadStream,
1235 property_name: Option<&CFStreamPropertyKey>,
1236 property_value: Option<&CFType>,
1237) -> bool {
1238 extern "C-unwind" {
1239 fn CFReadStreamSetProperty(
1240 stream: &CFReadStream,
1241 property_name: Option<&CFStreamPropertyKey>,
1242 property_value: Option<&CFType>,
1243 ) -> Boolean;
1244 }
1245 let ret = unsafe { CFReadStreamSetProperty(stream, property_name, property_value) };
1246 ret != 0
1247}
1248
1249#[deprecated = "renamed to `CFWriteStream::set_property`"]
1250#[inline]
1251pub unsafe extern "C-unwind" fn CFWriteStreamSetProperty(
1252 stream: &CFWriteStream,
1253 property_name: Option<&CFStreamPropertyKey>,
1254 property_value: Option<&CFType>,
1255) -> bool {
1256 extern "C-unwind" {
1257 fn CFWriteStreamSetProperty(
1258 stream: &CFWriteStream,
1259 property_name: Option<&CFStreamPropertyKey>,
1260 property_value: Option<&CFType>,
1261 ) -> Boolean;
1262 }
1263 let ret = unsafe { CFWriteStreamSetProperty(stream, property_name, property_value) };
1264 ret != 0
1265}
1266
1267#[deprecated = "renamed to `CFReadStream::set_client`"]
1268#[inline]
1269pub unsafe extern "C-unwind" fn CFReadStreamSetClient(
1270 stream: &CFReadStream,
1271 stream_events: CFOptionFlags,
1272 client_cb: CFReadStreamClientCallBack,
1273 client_context: *mut CFStreamClientContext,
1274) -> bool {
1275 extern "C-unwind" {
1276 fn CFReadStreamSetClient(
1277 stream: &CFReadStream,
1278 stream_events: CFOptionFlags,
1279 client_cb: CFReadStreamClientCallBack,
1280 client_context: *mut CFStreamClientContext,
1281 ) -> Boolean;
1282 }
1283 let ret = unsafe { CFReadStreamSetClient(stream, stream_events, client_cb, client_context) };
1284 ret != 0
1285}
1286
1287#[deprecated = "renamed to `CFWriteStream::set_client`"]
1288#[inline]
1289pub unsafe extern "C-unwind" fn CFWriteStreamSetClient(
1290 stream: &CFWriteStream,
1291 stream_events: CFOptionFlags,
1292 client_cb: CFWriteStreamClientCallBack,
1293 client_context: *mut CFStreamClientContext,
1294) -> bool {
1295 extern "C-unwind" {
1296 fn CFWriteStreamSetClient(
1297 stream: &CFWriteStream,
1298 stream_events: CFOptionFlags,
1299 client_cb: CFWriteStreamClientCallBack,
1300 client_context: *mut CFStreamClientContext,
1301 ) -> Boolean;
1302 }
1303 let ret = unsafe { CFWriteStreamSetClient(stream, stream_events, client_cb, client_context) };
1304 ret != 0
1305}
1306
1307#[cfg(feature = "CFRunLoop")]
1308#[deprecated = "renamed to `CFReadStream::schedule_with_run_loop`"]
1309#[inline]
1310pub extern "C-unwind" fn CFReadStreamScheduleWithRunLoop(
1311 stream: &CFReadStream,
1312 run_loop: Option<&CFRunLoop>,
1313 run_loop_mode: Option<&CFRunLoopMode>,
1314) {
1315 extern "C-unwind" {
1316 fn CFReadStreamScheduleWithRunLoop(
1317 stream: &CFReadStream,
1318 run_loop: Option<&CFRunLoop>,
1319 run_loop_mode: Option<&CFRunLoopMode>,
1320 );
1321 }
1322 unsafe { CFReadStreamScheduleWithRunLoop(stream, run_loop, run_loop_mode) }
1323}
1324
1325#[cfg(feature = "CFRunLoop")]
1326#[deprecated = "renamed to `CFWriteStream::schedule_with_run_loop`"]
1327#[inline]
1328pub extern "C-unwind" fn CFWriteStreamScheduleWithRunLoop(
1329 stream: &CFWriteStream,
1330 run_loop: Option<&CFRunLoop>,
1331 run_loop_mode: Option<&CFRunLoopMode>,
1332) {
1333 extern "C-unwind" {
1334 fn CFWriteStreamScheduleWithRunLoop(
1335 stream: &CFWriteStream,
1336 run_loop: Option<&CFRunLoop>,
1337 run_loop_mode: Option<&CFRunLoopMode>,
1338 );
1339 }
1340 unsafe { CFWriteStreamScheduleWithRunLoop(stream, run_loop, run_loop_mode) }
1341}
1342
1343#[cfg(feature = "CFRunLoop")]
1344#[deprecated = "renamed to `CFReadStream::unschedule_from_run_loop`"]
1345#[inline]
1346pub extern "C-unwind" fn CFReadStreamUnscheduleFromRunLoop(
1347 stream: &CFReadStream,
1348 run_loop: Option<&CFRunLoop>,
1349 run_loop_mode: Option<&CFRunLoopMode>,
1350) {
1351 extern "C-unwind" {
1352 fn CFReadStreamUnscheduleFromRunLoop(
1353 stream: &CFReadStream,
1354 run_loop: Option<&CFRunLoop>,
1355 run_loop_mode: Option<&CFRunLoopMode>,
1356 );
1357 }
1358 unsafe { CFReadStreamUnscheduleFromRunLoop(stream, run_loop, run_loop_mode) }
1359}
1360
1361#[cfg(feature = "CFRunLoop")]
1362#[deprecated = "renamed to `CFWriteStream::unschedule_from_run_loop`"]
1363#[inline]
1364pub extern "C-unwind" fn CFWriteStreamUnscheduleFromRunLoop(
1365 stream: &CFWriteStream,
1366 run_loop: Option<&CFRunLoop>,
1367 run_loop_mode: Option<&CFRunLoopMode>,
1368) {
1369 extern "C-unwind" {
1370 fn CFWriteStreamUnscheduleFromRunLoop(
1371 stream: &CFWriteStream,
1372 run_loop: Option<&CFRunLoop>,
1373 run_loop_mode: Option<&CFRunLoopMode>,
1374 );
1375 }
1376 unsafe { CFWriteStreamUnscheduleFromRunLoop(stream, run_loop, run_loop_mode) }
1377}
1378
1379extern "C-unwind" {
1380 #[cfg(feature = "dispatch2")]
1381 #[deprecated = "renamed to `CFReadStream::set_dispatch_queue`"]
1382 pub fn CFReadStreamSetDispatchQueue(stream: &CFReadStream, q: Option<&DispatchQueue>);
1383}
1384
1385extern "C-unwind" {
1386 #[cfg(feature = "dispatch2")]
1387 #[deprecated = "renamed to `CFWriteStream::set_dispatch_queue`"]
1388 pub fn CFWriteStreamSetDispatchQueue(stream: &CFWriteStream, q: Option<&DispatchQueue>);
1389}
1390
1391#[cfg(feature = "dispatch2")]
1392#[deprecated = "renamed to `CFReadStream::dispatch_queue`"]
1393#[inline]
1394pub extern "C-unwind" fn CFReadStreamCopyDispatchQueue(
1395 stream: &CFReadStream,
1396) -> Option<DispatchRetained<DispatchQueue>> {
1397 extern "C-unwind" {
1398 fn CFReadStreamCopyDispatchQueue(stream: &CFReadStream) -> Option<NonNull<DispatchQueue>>;
1399 }
1400 let ret = unsafe { CFReadStreamCopyDispatchQueue(stream) };
1401 ret.map(|ret| unsafe { DispatchRetained::from_raw(ret) })
1402}
1403
1404#[cfg(feature = "dispatch2")]
1405#[deprecated = "renamed to `CFWriteStream::dispatch_queue`"]
1406#[inline]
1407pub extern "C-unwind" fn CFWriteStreamCopyDispatchQueue(
1408 stream: &CFWriteStream,
1409) -> Option<DispatchRetained<DispatchQueue>> {
1410 extern "C-unwind" {
1411 fn CFWriteStreamCopyDispatchQueue(stream: &CFWriteStream)
1412 -> Option<NonNull<DispatchQueue>>;
1413 }
1414 let ret = unsafe { CFWriteStreamCopyDispatchQueue(stream) };
1415 ret.map(|ret| unsafe { DispatchRetained::from_raw(ret) })
1416}
1417
1418#[deprecated = "renamed to `CFReadStream::error`"]
1419#[inline]
1420pub extern "C-unwind" fn CFReadStreamGetError(stream: &CFReadStream) -> CFStreamError {
1421 extern "C-unwind" {
1422 fn CFReadStreamGetError(stream: &CFReadStream) -> CFStreamError;
1423 }
1424 unsafe { CFReadStreamGetError(stream) }
1425}
1426
1427#[deprecated = "renamed to `CFWriteStream::error`"]
1428#[inline]
1429pub extern "C-unwind" fn CFWriteStreamGetError(stream: &CFWriteStream) -> CFStreamError {
1430 extern "C-unwind" {
1431 fn CFWriteStreamGetError(stream: &CFWriteStream) -> CFStreamError;
1432 }
1433 unsafe { CFWriteStreamGetError(stream) }
1434}