Skip to main content

ohos_netstack_sys/net_http/
net_http_ffi.rs

1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6use crate::net_http_type::*;
7
8extern "C" {
9    /// Creates headers for a request or response.
10    ///
11    ///
12    /// # Returns
13    ///
14    /// * Http_Headers* Pointer to [`Http_Headers`].
15    ///
16    /// Required System Capabilities: SystemCapability.Communication.NetStack
17    ///
18    /// Available since API-level: 20
19    #[cfg(feature = "api-20")]
20    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
21    pub fn OH_Http_CreateHeaders() -> *mut Http_Headers;
22    /// Destroys the headers of a request or response.
23    ///
24    /// # Arguments
25    ///
26    /// * `headers` - Pointer to the [`Http_Headers`] to be destroyed, headers ends with null.
27    ///
28    /// Required System Capabilities: SystemCapability.Communication.NetStack
29    ///
30    /// Available since API-level: 20
31    #[cfg(feature = "api-20")]
32    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
33    pub fn OH_Http_DestroyHeaders(headers: *mut *mut Http_Headers);
34    /// Sets the key-value pair of the request or response header.
35    ///
36    /// # Arguments
37    ///
38    /// * `headers` - Pointer to the [`Http_Headers`] to be set.
39    ///
40    /// * `name` - Key.
41    ///
42    /// * `value` - Value.
43    ///
44    /// # Returns
45    ///
46    /// * uint32_t 0 - success. 401 - Parameter error. 2300027 - Out of memory.
47    ///
48    /// Required System Capabilities: SystemCapability.Communication.NetStack
49    ///
50    /// Available since API-level: 20
51    #[cfg(feature = "api-20")]
52    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
53    pub fn OH_Http_SetHeaderValue(
54        headers: *mut Http_Headers,
55        name: *const ::core::ffi::c_char,
56        value: *const ::core::ffi::c_char,
57    ) -> u32;
58    /// Obtains the value of a request or response header by key.
59    ///
60    /// # Arguments
61    ///
62    /// * `headers` - Pointer to [`Http_Headers`].
63    ///
64    /// * `name` - Key.
65    ///
66    /// # Returns
67    ///
68    /// * Http_HeaderValue* Pointer to the obtained [`Http_HeaderValue`].
69    ///
70    /// Required System Capabilities: SystemCapability.Communication.NetStack
71    ///
72    /// Available since API-level: 20
73    #[cfg(feature = "api-20")]
74    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
75    pub fn OH_Http_GetHeaderValue(
76        headers: *mut Http_Headers,
77        name: *const ::core::ffi::c_char,
78    ) -> *mut Http_HeaderValue;
79    /// Obtains all the key-value pairs of a request or response header.
80    ///
81    /// # Arguments
82    ///
83    /// * `headers` - Pointer to [`Http_Headersaders`].
84    ///
85    /// # Returns
86    ///
87    /// * Http_HeaderEntry* Pointers to all obtained key-value pairs [`Http_HeaderEntry`].
88    ///
89    /// Required System Capabilities: SystemCapability.Communication.NetStack
90    ///
91    /// Available since API-level: 20
92    #[cfg(feature = "api-20")]
93    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
94    pub fn OH_Http_GetHeaderEntries(headers: *mut Http_Headers) -> *mut Http_HeaderEntry;
95    /// Destroys all key-value pairs obtained in [`OH_Http_GetHeaderEntries`].
96    ///
97    /// # Arguments
98    ///
99    /// * `headerEntry` - Pointer to the [`Http_HeaderEntry`] to be destroyed, headerEntry ends with null.
100    ///
101    /// Required System Capabilities: SystemCapability.Communication.NetStack
102    ///
103    /// Available since API-level: 20
104    #[cfg(feature = "api-20")]
105    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
106    pub fn OH_Http_DestroyHeaderEntries(headerEntry: *mut *mut Http_HeaderEntry);
107    /// Create a http request.
108    ///
109    /// # Arguments
110    ///
111    /// * `url` - Http request url.
112    ///
113    /// # Returns
114    ///
115    /// * Pointer of HttpRequest if success; Null otherwise.
116    ///
117    /// Required System Capabilities: SystemCapability.Communication.NetStack
118    ///
119    /// Available since API-level: 20
120    #[cfg(feature = "api-20")]
121    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
122    pub fn OH_Http_CreateRequest(url: *const ::core::ffi::c_char) -> *mut Http_Request;
123    /// Initiates an HTTP request.
124    ///
125    /// # Arguments
126    ///
127    /// * `request` - Pointer to [`Http_Request`].
128    ///
129    /// * `callback` - Http response info, pointer to [`Http_ResponseCallback`]
130    ///
131    /// * `handler` - Callbacks to watch different events, pointer to [`Http_EventsHandler`].
132    ///
133    /// # Returns
134    ///
135    /// * 0 if success; non-0 otherwise. For details about error codes, see [`Http_ErrCode`].
136    /// ohos.permission.INTERNET
137    ///
138    /// Required System Capabilities: SystemCapability.Communication.NetStack
139    ///
140    /// Available since API-level: 20
141    #[cfg(feature = "api-20")]
142    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
143    pub fn OH_Http_Request(
144        request: *mut Http_Request,
145        callback: Http_ResponseCallback,
146        handler: Http_EventsHandler,
147    ) -> ::core::ffi::c_int;
148    /// Destroy the HTTP request.
149    ///
150    /// # Arguments
151    ///
152    /// * `request` - Pointer to the http request [`Http_Request`].
153    ///
154    /// Required System Capabilities: SystemCapability.Communication.NetStack
155    ///
156    /// Available since API-level: 20
157    #[cfg(feature = "api-20")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
159    pub fn OH_Http_Destroy(request: *mut *mut Http_Request);
160}