objc2-cf-network 0.3.2

Bindings to the CFNetwork framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreamerrordomainhttp?language=objc)
    pub static kCFStreamErrorDomainHTTP: i32;
}

/// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/cfstreamerrorhttp?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CFStreamErrorHTTP(pub c_int);
impl CFStreamErrorHTTP {
    #[doc(alias = "kCFStreamErrorHTTPParseFailure")]
    pub const ParseFailure: Self = Self(-1);
    #[doc(alias = "kCFStreamErrorHTTPRedirectionLoop")]
    pub const RedirectionLoop: Self = Self(-2);
    #[doc(alias = "kCFStreamErrorHTTPBadURL")]
    pub const BadURL: Self = Self(-3);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CFStreamErrorHTTP {
    const ENCODING: Encoding = c_int::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CFStreamErrorHTTP {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpresponseheader?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPResponseHeader: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpfinalurl?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPFinalURL: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpfinalrequest?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPFinalRequest: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpproxy?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPProxy: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpproxyhost?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPProxyHost: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpproxyport?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPProxyPort: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpsproxyhost?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPSProxyHost: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpsproxyport?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPSProxyPort: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpshouldautoredirect?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPShouldAutoredirect: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttpattemptpersistentconnection?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPAttemptPersistentConnection: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreampropertyhttprequestbyteswrittencount?language=objc)
    #[deprecated = "Use NSURLSession API for http requests"]
    pub static kCFStreamPropertyHTTPRequestBytesWrittenCount: &'static CFString;
}

#[cfg(feature = "CFHTTPMessage")]
#[deprecated = "Use NSURLSession API for http requests"]
#[inline]
pub unsafe extern "C-unwind" fn CFReadStreamCreateForHTTPRequest(
    alloc: Option<&CFAllocator>,
    request: &CFHTTPMessage,
) -> CFRetained<CFReadStream> {
    extern "C-unwind" {
        fn CFReadStreamCreateForHTTPRequest(
            alloc: Option<&CFAllocator>,
            request: &CFHTTPMessage,
        ) -> Option<NonNull<CFReadStream>>;
    }
    let ret = unsafe { CFReadStreamCreateForHTTPRequest(alloc, request) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

#[cfg(feature = "CFHTTPMessage")]
#[deprecated = "Use NSURLSession API for http requests"]
#[inline]
pub unsafe extern "C-unwind" fn CFReadStreamCreateForStreamedHTTPRequest(
    alloc: Option<&CFAllocator>,
    request_headers: &CFHTTPMessage,
    request_body: &CFReadStream,
) -> CFRetained<CFReadStream> {
    extern "C-unwind" {
        fn CFReadStreamCreateForStreamedHTTPRequest(
            alloc: Option<&CFAllocator>,
            request_headers: &CFHTTPMessage,
            request_body: &CFReadStream,
        ) -> Option<NonNull<CFReadStream>>;
    }
    let ret =
        unsafe { CFReadStreamCreateForStreamedHTTPRequest(alloc, request_headers, request_body) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}