objc2_core_foundation/generated/
CFStream.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstreamerror?language=objc)
13#[cfg(feature = "CFBase")]
14#[repr(C)]
15#[derive(Clone, Copy, Debug, PartialEq)]
16pub struct CFStreamError {
17    pub domain: CFIndex,
18    pub error: i32,
19}
20
21#[cfg(all(feature = "CFBase", feature = "objc2"))]
22unsafe impl Encode for CFStreamError {
23    const ENCODING: Encoding = Encoding::Struct("?", &[<CFIndex>::ENCODING, <i32>::ENCODING]);
24}
25
26#[cfg(all(feature = "CFBase", feature = "objc2"))]
27unsafe impl RefEncode for CFStreamError {
28    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
29}
30
31/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstreampropertykey?language=objc)
32// NS_TYPED_EXTENSIBLE_ENUM
33#[cfg(feature = "CFBase")]
34pub type CFStreamPropertyKey = CFString;
35
36/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstreamstatus?language=objc)
37// NS_ENUM
38#[cfg(feature = "CFBase")]
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct CFStreamStatus(pub CFIndex);
42#[cfg(feature = "CFBase")]
43impl CFStreamStatus {
44    #[doc(alias = "kCFStreamStatusNotOpen")]
45    pub const NotOpen: Self = Self(0);
46    #[doc(alias = "kCFStreamStatusOpening")]
47    pub const Opening: Self = Self(1);
48    #[doc(alias = "kCFStreamStatusOpen")]
49    pub const Open: Self = Self(2);
50    #[doc(alias = "kCFStreamStatusReading")]
51    pub const Reading: Self = Self(3);
52    #[doc(alias = "kCFStreamStatusWriting")]
53    pub const Writing: Self = Self(4);
54    #[doc(alias = "kCFStreamStatusAtEnd")]
55    pub const AtEnd: Self = Self(5);
56    #[doc(alias = "kCFStreamStatusClosed")]
57    pub const Closed: Self = Self(6);
58    #[doc(alias = "kCFStreamStatusError")]
59    pub const Error: Self = Self(7);
60}
61
62#[cfg(all(feature = "CFBase", feature = "objc2"))]
63unsafe impl Encode for CFStreamStatus {
64    const ENCODING: Encoding = CFIndex::ENCODING;
65}
66
67#[cfg(all(feature = "CFBase", feature = "objc2"))]
68unsafe impl RefEncode for CFStreamStatus {
69    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
70}
71
72/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstreameventtype?language=objc)
73// NS_OPTIONS
74#[cfg(feature = "CFBase")]
75#[repr(transparent)]
76#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
77pub struct CFStreamEventType(pub CFOptionFlags);
78#[cfg(feature = "CFBase")]
79bitflags::bitflags! {
80    impl CFStreamEventType: CFOptionFlags {
81        #[doc(alias = "kCFStreamEventNone")]
82        const None = 0;
83        #[doc(alias = "kCFStreamEventOpenCompleted")]
84        const OpenCompleted = 1;
85        #[doc(alias = "kCFStreamEventHasBytesAvailable")]
86        const HasBytesAvailable = 2;
87        #[doc(alias = "kCFStreamEventCanAcceptBytes")]
88        const CanAcceptBytes = 4;
89        #[doc(alias = "kCFStreamEventErrorOccurred")]
90        const ErrorOccurred = 8;
91        #[doc(alias = "kCFStreamEventEndEncountered")]
92        const EndEncountered = 16;
93    }
94}
95
96#[cfg(all(feature = "CFBase", feature = "objc2"))]
97unsafe impl Encode for CFStreamEventType {
98    const ENCODING: Encoding = CFOptionFlags::ENCODING;
99}
100
101#[cfg(all(feature = "CFBase", feature = "objc2"))]
102unsafe impl RefEncode for CFStreamEventType {
103    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
104}
105
106/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstreamclientcontext?language=objc)
107#[cfg(feature = "CFBase")]
108#[repr(C)]
109#[derive(Clone, Copy, Debug, PartialEq)]
110pub struct CFStreamClientContext {
111    pub version: CFIndex,
112    pub info: *mut c_void,
113    pub retain: Option<unsafe extern "C-unwind" fn(*mut c_void) -> *mut c_void>,
114    pub release: Option<unsafe extern "C-unwind" fn(*mut c_void)>,
115    pub copyDescription: Option<unsafe extern "C-unwind" fn(*mut c_void) -> *const CFString>,
116}
117
118#[cfg(all(feature = "CFBase", feature = "objc2"))]
119unsafe impl Encode for CFStreamClientContext {
120    const ENCODING: Encoding = Encoding::Struct(
121        "?",
122        &[
123            <CFIndex>::ENCODING,
124            <*mut c_void>::ENCODING,
125            <Option<unsafe extern "C-unwind" fn(*mut c_void) -> *mut c_void>>::ENCODING,
126            <Option<unsafe extern "C-unwind" fn(*mut c_void)>>::ENCODING,
127            <Option<unsafe extern "C-unwind" fn(*mut c_void) -> *const CFString>>::ENCODING,
128        ],
129    );
130}
131
132#[cfg(all(feature = "CFBase", feature = "objc2"))]
133unsafe impl RefEncode for CFStreamClientContext {
134    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
135}
136
137/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfreadstream?language=objc)
138#[repr(C)]
139pub struct CFReadStream {
140    inner: [u8; 0],
141    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
142}
143
144cf_type!(
145    #[encoding_name = "__CFReadStream"]
146    unsafe impl CFReadStream {}
147);
148
149/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfwritestream?language=objc)
150#[repr(C)]
151pub struct CFWriteStream {
152    inner: [u8; 0],
153    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
154}
155
156cf_type!(
157    #[encoding_name = "__CFWriteStream"]
158    unsafe impl CFWriteStream {}
159);
160
161/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfreadstreamclientcallback?language=objc)
162#[cfg(feature = "CFBase")]
163pub type CFReadStreamClientCallBack =
164    Option<unsafe extern "C-unwind" fn(*mut CFReadStream, CFStreamEventType, *mut c_void)>;
165
166/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfwritestreamclientcallback?language=objc)
167#[cfg(feature = "CFBase")]
168pub type CFWriteStreamClientCallBack =
169    Option<unsafe extern "C-unwind" fn(*mut CFWriteStream, CFStreamEventType, *mut c_void)>;
170
171#[cfg(feature = "CFBase")]
172unsafe impl ConcreteType for CFReadStream {
173    #[doc(alias = "CFReadStreamGetTypeID")]
174    #[inline]
175    fn type_id() -> CFTypeID {
176        extern "C-unwind" {
177            fn CFReadStreamGetTypeID() -> CFTypeID;
178        }
179        unsafe { CFReadStreamGetTypeID() }
180    }
181}
182
183#[cfg(feature = "CFBase")]
184unsafe impl ConcreteType for CFWriteStream {
185    #[doc(alias = "CFWriteStreamGetTypeID")]
186    #[inline]
187    fn type_id() -> CFTypeID {
188        extern "C-unwind" {
189            fn CFWriteStreamGetTypeID() -> CFTypeID;
190        }
191        unsafe { CFWriteStreamGetTypeID() }
192    }
193}
194
195extern "C" {
196    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertydatawritten?language=objc)
197    #[cfg(feature = "CFBase")]
198    pub static kCFStreamPropertyDataWritten: Option<&'static CFStreamPropertyKey>;
199}
200
201#[cfg(feature = "CFBase")]
202#[inline]
203pub unsafe extern "C-unwind" fn CFReadStreamCreateWithBytesNoCopy(
204    alloc: Option<&CFAllocator>,
205    bytes: *const u8,
206    length: CFIndex,
207    bytes_deallocator: Option<&CFAllocator>,
208) -> Option<CFRetained<CFReadStream>> {
209    extern "C-unwind" {
210        fn CFReadStreamCreateWithBytesNoCopy(
211            alloc: Option<&CFAllocator>,
212            bytes: *const u8,
213            length: CFIndex,
214            bytes_deallocator: Option<&CFAllocator>,
215        ) -> Option<NonNull<CFReadStream>>;
216    }
217    let ret = unsafe { CFReadStreamCreateWithBytesNoCopy(alloc, bytes, length, bytes_deallocator) };
218    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
219}
220
221#[cfg(feature = "CFBase")]
222#[inline]
223pub unsafe extern "C-unwind" fn CFWriteStreamCreateWithBuffer(
224    alloc: Option<&CFAllocator>,
225    buffer: *mut u8,
226    buffer_capacity: CFIndex,
227) -> Option<CFRetained<CFWriteStream>> {
228    extern "C-unwind" {
229        fn CFWriteStreamCreateWithBuffer(
230            alloc: Option<&CFAllocator>,
231            buffer: *mut u8,
232            buffer_capacity: CFIndex,
233        ) -> Option<NonNull<CFWriteStream>>;
234    }
235    let ret = unsafe { CFWriteStreamCreateWithBuffer(alloc, buffer, buffer_capacity) };
236    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
237}
238
239#[cfg(feature = "CFBase")]
240#[inline]
241pub unsafe extern "C-unwind" fn CFWriteStreamCreateWithAllocatedBuffers(
242    alloc: Option<&CFAllocator>,
243    buffer_allocator: Option<&CFAllocator>,
244) -> Option<CFRetained<CFWriteStream>> {
245    extern "C-unwind" {
246        fn CFWriteStreamCreateWithAllocatedBuffers(
247            alloc: Option<&CFAllocator>,
248            buffer_allocator: Option<&CFAllocator>,
249        ) -> Option<NonNull<CFWriteStream>>;
250    }
251    let ret = unsafe { CFWriteStreamCreateWithAllocatedBuffers(alloc, buffer_allocator) };
252    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
253}
254
255#[cfg(all(feature = "CFBase", feature = "CFURL"))]
256#[inline]
257pub unsafe extern "C-unwind" fn CFReadStreamCreateWithFile(
258    alloc: Option<&CFAllocator>,
259    file_url: Option<&CFURL>,
260) -> Option<CFRetained<CFReadStream>> {
261    extern "C-unwind" {
262        fn CFReadStreamCreateWithFile(
263            alloc: Option<&CFAllocator>,
264            file_url: Option<&CFURL>,
265        ) -> Option<NonNull<CFReadStream>>;
266    }
267    let ret = unsafe { CFReadStreamCreateWithFile(alloc, file_url) };
268    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
269}
270
271#[cfg(all(feature = "CFBase", feature = "CFURL"))]
272#[inline]
273pub unsafe extern "C-unwind" fn CFWriteStreamCreateWithFile(
274    alloc: Option<&CFAllocator>,
275    file_url: Option<&CFURL>,
276) -> Option<CFRetained<CFWriteStream>> {
277    extern "C-unwind" {
278        fn CFWriteStreamCreateWithFile(
279            alloc: Option<&CFAllocator>,
280            file_url: Option<&CFURL>,
281        ) -> Option<NonNull<CFWriteStream>>;
282    }
283    let ret = unsafe { CFWriteStreamCreateWithFile(alloc, file_url) };
284    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
285}
286
287extern "C-unwind" {
288    #[cfg(feature = "CFBase")]
289    pub fn CFStreamCreateBoundPair(
290        alloc: Option<&CFAllocator>,
291        read_stream: *mut *mut CFReadStream,
292        write_stream: *mut *mut CFWriteStream,
293        transfer_buffer_size: CFIndex,
294    );
295}
296
297extern "C" {
298    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertyappendtofile?language=objc)
299    #[cfg(feature = "CFBase")]
300    pub static kCFStreamPropertyAppendToFile: Option<&'static CFStreamPropertyKey>;
301}
302
303extern "C" {
304    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertyfilecurrentoffset?language=objc)
305    #[cfg(feature = "CFBase")]
306    pub static kCFStreamPropertyFileCurrentOffset: Option<&'static CFStreamPropertyKey>;
307}
308
309extern "C" {
310    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocketnativehandle?language=objc)
311    #[cfg(feature = "CFBase")]
312    pub static kCFStreamPropertySocketNativeHandle: Option<&'static CFStreamPropertyKey>;
313}
314
315extern "C" {
316    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocketremotehostname?language=objc)
317    #[cfg(feature = "CFBase")]
318    pub static kCFStreamPropertySocketRemoteHostName: Option<&'static CFStreamPropertyKey>;
319}
320
321extern "C" {
322    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocketremoteportnumber?language=objc)
323    #[cfg(feature = "CFBase")]
324    pub static kCFStreamPropertySocketRemotePortNumber: Option<&'static CFStreamPropertyKey>;
325}
326
327extern "C" {
328    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamerrordomainsocks?language=objc)
329    pub static kCFStreamErrorDomainSOCKS: c_int;
330}
331
332extern "C" {
333    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocksproxy?language=objc)
334    #[cfg(feature = "CFBase")]
335    pub static kCFStreamPropertySOCKSProxy: &'static CFString;
336}
337
338extern "C" {
339    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocksproxyhost?language=objc)
340    #[cfg(feature = "CFBase")]
341    pub static kCFStreamPropertySOCKSProxyHost: &'static CFString;
342}
343
344extern "C" {
345    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocksproxyport?language=objc)
346    #[cfg(feature = "CFBase")]
347    pub static kCFStreamPropertySOCKSProxyPort: &'static CFString;
348}
349
350extern "C" {
351    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocksversion?language=objc)
352    #[cfg(feature = "CFBase")]
353    pub static kCFStreamPropertySOCKSVersion: &'static CFString;
354}
355
356extern "C" {
357    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsocksversion4?language=objc)
358    #[cfg(feature = "CFBase")]
359    pub static kCFStreamSocketSOCKSVersion4: &'static CFString;
360}
361
362extern "C" {
363    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsocksversion5?language=objc)
364    #[cfg(feature = "CFBase")]
365    pub static kCFStreamSocketSOCKSVersion5: &'static CFString;
366}
367
368extern "C" {
369    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocksuser?language=objc)
370    #[cfg(feature = "CFBase")]
371    pub static kCFStreamPropertySOCKSUser: &'static CFString;
372}
373
374extern "C" {
375    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysockspassword?language=objc)
376    #[cfg(feature = "CFBase")]
377    pub static kCFStreamPropertySOCKSPassword: &'static CFString;
378}
379
380extern "C" {
381    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamerrordomainssl?language=objc)
382    pub static kCFStreamErrorDomainSSL: c_int;
383}
384
385extern "C" {
386    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertysocketsecuritylevel?language=objc)
387    #[cfg(feature = "CFBase")]
388    pub static kCFStreamPropertySocketSecurityLevel: &'static CFString;
389}
390
391extern "C" {
392    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsecuritylevelnone?language=objc)
393    #[cfg(feature = "CFBase")]
394    pub static kCFStreamSocketSecurityLevelNone: &'static CFString;
395}
396
397extern "C" {
398    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsecuritylevelsslv2?language=objc)
399    #[cfg(feature = "CFBase")]
400    pub static kCFStreamSocketSecurityLevelSSLv2: &'static CFString;
401}
402
403extern "C" {
404    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsecuritylevelsslv3?language=objc)
405    #[cfg(feature = "CFBase")]
406    pub static kCFStreamSocketSecurityLevelSSLv3: &'static CFString;
407}
408
409extern "C" {
410    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsecurityleveltlsv1?language=objc)
411    #[cfg(feature = "CFBase")]
412    pub static kCFStreamSocketSecurityLevelTLSv1: &'static CFString;
413}
414
415extern "C" {
416    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreamsocketsecuritylevelnegotiatedssl?language=objc)
417    #[cfg(feature = "CFBase")]
418    pub static kCFStreamSocketSecurityLevelNegotiatedSSL: &'static CFString;
419}
420
421extern "C" {
422    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstreampropertyshouldclosenativesocket?language=objc)
423    #[cfg(feature = "CFBase")]
424    pub static kCFStreamPropertyShouldCloseNativeSocket: &'static CFString;
425}
426
427extern "C-unwind" {
428    #[cfg(all(feature = "CFBase", feature = "CFSocket"))]
429    #[deprecated = "Use nw_connection_t in Network framework instead"]
430    pub fn CFStreamCreatePairWithSocket(
431        alloc: Option<&CFAllocator>,
432        sock: CFSocketNativeHandle,
433        read_stream: *mut *mut CFReadStream,
434        write_stream: *mut *mut CFWriteStream,
435    );
436}
437
438extern "C-unwind" {
439    #[cfg(feature = "CFBase")]
440    #[deprecated = "Use nw_connection_t in Network framework instead"]
441    pub fn CFStreamCreatePairWithSocketToHost(
442        alloc: Option<&CFAllocator>,
443        host: Option<&CFString>,
444        port: u32,
445        read_stream: *mut *mut CFReadStream,
446        write_stream: *mut *mut CFWriteStream,
447    );
448}
449
450extern "C-unwind" {
451    #[cfg(all(feature = "CFBase", feature = "CFData", feature = "CFSocket"))]
452    #[deprecated = "Use nw_connection_t in Network framework instead"]
453    pub fn CFStreamCreatePairWithPeerSocketSignature(
454        alloc: Option<&CFAllocator>,
455        signature: *const CFSocketSignature,
456        read_stream: *mut *mut CFReadStream,
457        write_stream: *mut *mut CFWriteStream,
458    );
459}
460
461extern "C-unwind" {
462    #[cfg(feature = "CFBase")]
463    pub fn CFReadStreamGetStatus(stream: &CFReadStream) -> CFStreamStatus;
464}
465
466extern "C-unwind" {
467    #[cfg(feature = "CFBase")]
468    pub fn CFWriteStreamGetStatus(stream: &CFWriteStream) -> CFStreamStatus;
469}
470
471#[cfg(feature = "CFError")]
472#[inline]
473pub unsafe extern "C-unwind" fn CFReadStreamCopyError(
474    stream: &CFReadStream,
475) -> Option<CFRetained<CFError>> {
476    extern "C-unwind" {
477        fn CFReadStreamCopyError(stream: &CFReadStream) -> Option<NonNull<CFError>>;
478    }
479    let ret = unsafe { CFReadStreamCopyError(stream) };
480    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
481}
482
483#[cfg(feature = "CFError")]
484#[inline]
485pub unsafe extern "C-unwind" fn CFWriteStreamCopyError(
486    stream: &CFWriteStream,
487) -> Option<CFRetained<CFError>> {
488    extern "C-unwind" {
489        fn CFWriteStreamCopyError(stream: &CFWriteStream) -> Option<NonNull<CFError>>;
490    }
491    let ret = unsafe { CFWriteStreamCopyError(stream) };
492    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
493}
494
495#[inline]
496pub unsafe extern "C-unwind" fn CFReadStreamOpen(stream: &CFReadStream) -> bool {
497    extern "C-unwind" {
498        fn CFReadStreamOpen(stream: &CFReadStream) -> Boolean;
499    }
500    let ret = unsafe { CFReadStreamOpen(stream) };
501    ret != 0
502}
503
504#[inline]
505pub unsafe extern "C-unwind" fn CFWriteStreamOpen(stream: &CFWriteStream) -> bool {
506    extern "C-unwind" {
507        fn CFWriteStreamOpen(stream: &CFWriteStream) -> Boolean;
508    }
509    let ret = unsafe { CFWriteStreamOpen(stream) };
510    ret != 0
511}
512
513extern "C-unwind" {
514    pub fn CFReadStreamClose(stream: &CFReadStream);
515}
516
517extern "C-unwind" {
518    pub fn CFWriteStreamClose(stream: &CFWriteStream);
519}
520
521#[inline]
522pub unsafe extern "C-unwind" fn CFReadStreamHasBytesAvailable(stream: &CFReadStream) -> bool {
523    extern "C-unwind" {
524        fn CFReadStreamHasBytesAvailable(stream: &CFReadStream) -> Boolean;
525    }
526    let ret = unsafe { CFReadStreamHasBytesAvailable(stream) };
527    ret != 0
528}
529
530extern "C-unwind" {
531    #[cfg(feature = "CFBase")]
532    pub fn CFReadStreamRead(
533        stream: &CFReadStream,
534        buffer: *mut u8,
535        buffer_length: CFIndex,
536    ) -> CFIndex;
537}
538
539extern "C-unwind" {
540    #[cfg(feature = "CFBase")]
541    pub fn CFReadStreamGetBuffer(
542        stream: &CFReadStream,
543        max_bytes_to_read: CFIndex,
544        num_bytes_read: *mut CFIndex,
545    ) -> *const u8;
546}
547
548#[inline]
549pub unsafe extern "C-unwind" fn CFWriteStreamCanAcceptBytes(stream: &CFWriteStream) -> bool {
550    extern "C-unwind" {
551        fn CFWriteStreamCanAcceptBytes(stream: &CFWriteStream) -> Boolean;
552    }
553    let ret = unsafe { CFWriteStreamCanAcceptBytes(stream) };
554    ret != 0
555}
556
557extern "C-unwind" {
558    #[cfg(feature = "CFBase")]
559    pub fn CFWriteStreamWrite(
560        stream: &CFWriteStream,
561        buffer: *const u8,
562        buffer_length: CFIndex,
563    ) -> CFIndex;
564}
565
566#[cfg(feature = "CFBase")]
567#[inline]
568pub unsafe extern "C-unwind" fn CFReadStreamCopyProperty(
569    stream: &CFReadStream,
570    property_name: Option<&CFStreamPropertyKey>,
571) -> Option<CFRetained<CFType>> {
572    extern "C-unwind" {
573        fn CFReadStreamCopyProperty(
574            stream: &CFReadStream,
575            property_name: Option<&CFStreamPropertyKey>,
576        ) -> Option<NonNull<CFType>>;
577    }
578    let ret = unsafe { CFReadStreamCopyProperty(stream, property_name) };
579    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
580}
581
582#[cfg(feature = "CFBase")]
583#[inline]
584pub unsafe extern "C-unwind" fn CFWriteStreamCopyProperty(
585    stream: &CFWriteStream,
586    property_name: Option<&CFStreamPropertyKey>,
587) -> Option<CFRetained<CFType>> {
588    extern "C-unwind" {
589        fn CFWriteStreamCopyProperty(
590            stream: &CFWriteStream,
591            property_name: Option<&CFStreamPropertyKey>,
592        ) -> Option<NonNull<CFType>>;
593    }
594    let ret = unsafe { CFWriteStreamCopyProperty(stream, property_name) };
595    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
596}
597
598#[cfg(feature = "CFBase")]
599#[inline]
600pub unsafe extern "C-unwind" fn CFReadStreamSetProperty(
601    stream: &CFReadStream,
602    property_name: Option<&CFStreamPropertyKey>,
603    property_value: Option<&CFType>,
604) -> bool {
605    extern "C-unwind" {
606        fn CFReadStreamSetProperty(
607            stream: &CFReadStream,
608            property_name: Option<&CFStreamPropertyKey>,
609            property_value: Option<&CFType>,
610        ) -> Boolean;
611    }
612    let ret = unsafe { CFReadStreamSetProperty(stream, property_name, property_value) };
613    ret != 0
614}
615
616#[cfg(feature = "CFBase")]
617#[inline]
618pub unsafe extern "C-unwind" fn CFWriteStreamSetProperty(
619    stream: &CFWriteStream,
620    property_name: Option<&CFStreamPropertyKey>,
621    property_value: Option<&CFType>,
622) -> bool {
623    extern "C-unwind" {
624        fn CFWriteStreamSetProperty(
625            stream: &CFWriteStream,
626            property_name: Option<&CFStreamPropertyKey>,
627            property_value: Option<&CFType>,
628        ) -> Boolean;
629    }
630    let ret = unsafe { CFWriteStreamSetProperty(stream, property_name, property_value) };
631    ret != 0
632}
633
634#[cfg(feature = "CFBase")]
635#[inline]
636pub unsafe extern "C-unwind" fn CFReadStreamSetClient(
637    stream: &CFReadStream,
638    stream_events: CFOptionFlags,
639    client_cb: CFReadStreamClientCallBack,
640    client_context: *mut CFStreamClientContext,
641) -> bool {
642    extern "C-unwind" {
643        fn CFReadStreamSetClient(
644            stream: &CFReadStream,
645            stream_events: CFOptionFlags,
646            client_cb: CFReadStreamClientCallBack,
647            client_context: *mut CFStreamClientContext,
648        ) -> Boolean;
649    }
650    let ret = unsafe { CFReadStreamSetClient(stream, stream_events, client_cb, client_context) };
651    ret != 0
652}
653
654#[cfg(feature = "CFBase")]
655#[inline]
656pub unsafe extern "C-unwind" fn CFWriteStreamSetClient(
657    stream: &CFWriteStream,
658    stream_events: CFOptionFlags,
659    client_cb: CFWriteStreamClientCallBack,
660    client_context: *mut CFStreamClientContext,
661) -> bool {
662    extern "C-unwind" {
663        fn CFWriteStreamSetClient(
664            stream: &CFWriteStream,
665            stream_events: CFOptionFlags,
666            client_cb: CFWriteStreamClientCallBack,
667            client_context: *mut CFStreamClientContext,
668        ) -> Boolean;
669    }
670    let ret = unsafe { CFWriteStreamSetClient(stream, stream_events, client_cb, client_context) };
671    ret != 0
672}
673
674extern "C-unwind" {
675    #[cfg(all(feature = "CFBase", feature = "CFRunLoop"))]
676    pub fn CFReadStreamScheduleWithRunLoop(
677        stream: &CFReadStream,
678        run_loop: Option<&CFRunLoop>,
679        run_loop_mode: Option<&CFRunLoopMode>,
680    );
681}
682
683extern "C-unwind" {
684    #[cfg(all(feature = "CFBase", feature = "CFRunLoop"))]
685    pub fn CFWriteStreamScheduleWithRunLoop(
686        stream: &CFWriteStream,
687        run_loop: Option<&CFRunLoop>,
688        run_loop_mode: Option<&CFRunLoopMode>,
689    );
690}
691
692extern "C-unwind" {
693    #[cfg(all(feature = "CFBase", feature = "CFRunLoop"))]
694    pub fn CFReadStreamUnscheduleFromRunLoop(
695        stream: &CFReadStream,
696        run_loop: Option<&CFRunLoop>,
697        run_loop_mode: Option<&CFRunLoopMode>,
698    );
699}
700
701extern "C-unwind" {
702    #[cfg(all(feature = "CFBase", feature = "CFRunLoop"))]
703    pub fn CFWriteStreamUnscheduleFromRunLoop(
704        stream: &CFWriteStream,
705        run_loop: Option<&CFRunLoop>,
706        run_loop_mode: Option<&CFRunLoopMode>,
707    );
708}
709
710/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstreamerrordomain?language=objc)
711// NS_ENUM
712#[cfg(feature = "CFBase")]
713#[repr(transparent)]
714#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
715pub struct CFStreamErrorDomain(pub CFIndex);
716#[cfg(feature = "CFBase")]
717impl CFStreamErrorDomain {
718    #[doc(alias = "kCFStreamErrorDomainCustom")]
719    pub const Custom: Self = Self(-1);
720    #[doc(alias = "kCFStreamErrorDomainPOSIX")]
721    pub const POSIX: Self = Self(1);
722    #[doc(alias = "kCFStreamErrorDomainMacOSStatus")]
723    pub const MacOSStatus: Self = Self(2);
724}
725
726#[cfg(all(feature = "CFBase", feature = "objc2"))]
727unsafe impl Encode for CFStreamErrorDomain {
728    const ENCODING: Encoding = CFIndex::ENCODING;
729}
730
731#[cfg(all(feature = "CFBase", feature = "objc2"))]
732unsafe impl RefEncode for CFStreamErrorDomain {
733    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
734}
735
736extern "C-unwind" {
737    #[cfg(feature = "CFBase")]
738    pub fn CFReadStreamGetError(stream: &CFReadStream) -> CFStreamError;
739}
740
741extern "C-unwind" {
742    #[cfg(feature = "CFBase")]
743    pub fn CFWriteStreamGetError(stream: &CFWriteStream) -> CFStreamError;
744}