Skip to main content

ohos_netstack_sys/net_websocket/
net_websocket_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_websocket_type::*;
7
8extern "C" {
9    /// Constructor of websocket.
10    ///
11    /// # Arguments
12    ///
13    /// * `onOpen` - Callback function invoked when a connection setup message is received.
14    ///
15    /// * `onMessage` - Callback function invoked when a message is received.
16    ///
17    /// * `onError` - Callback function invoked when a connection error message is received.
18    ///
19    /// * `onclose` - Callback function invoked when a connection closing message is closed.
20    ///
21    ///
22    /// # Returns
23    ///
24    /// * Pointer to the websocket client if success; NULL otherwise.
25    ///
26    /// Required System Capabilities: SystemCapability.Communication.NetStack
27    ///
28    /// Available since API-level: 11
29    ///
30    /// Version: 1.0
31    #[cfg(feature = "api-11")]
32    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
33    pub fn OH_WebSocketClient_Constructor(
34        onOpen: WebSocket_OnOpenCallback,
35        onMessage: WebSocket_OnMessageCallback,
36        onError: WebSocket_OnErrorCallback,
37        onclose: WebSocket_OnCloseCallback,
38    ) -> *mut WebSocket;
39    /// Adds the header information to the client request.
40    ///
41    /// # Arguments
42    ///
43    /// * `client` - Pointer to the websocket client.
44    ///
45    /// * `header` - Header information
46    ///
47    /// # Returns
48    ///
49    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
50    ///
51    /// Required System Capabilities: SystemCapability.Communication.NetStack
52    ///
53    /// Available since API-level: 11
54    ///
55    /// Version: 1.0
56    #[cfg(feature = "api-11")]
57    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
58    pub fn OH_WebSocketClient_AddHeader(
59        client: *mut WebSocket,
60        header: WebSocket_Header,
61    ) -> ::core::ffi::c_int;
62    /// Connects the client to the server.
63    ///
64    /// # Arguments
65    ///
66    /// * `client` - Pointer to the websocket client.
67    ///
68    /// * `url` - URL for the client to connect to the server.
69    ///
70    /// * `options` - Optional parameters.
71    ///
72    /// # Returns
73    ///
74    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
75    /// ohos.permission.INTERNET
76    ///
77    /// Required System Capabilities: SystemCapability.Communication.NetStack
78    ///
79    /// Available since API-level: 11
80    ///
81    /// Version: 1.0
82    #[cfg(feature = "api-11")]
83    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
84    pub fn OH_WebSocketClient_Connect(
85        client: *mut WebSocket,
86        url: *const ::core::ffi::c_char,
87        options: WebSocket_RequestOptions,
88    ) -> ::core::ffi::c_int;
89    /// Sends data from the client to the server.
90    ///
91    /// # Arguments
92    ///
93    /// * `client` - Pointer to the websocket client.
94    ///
95    /// * `data` - Data sent by the client.
96    ///
97    /// * `length` - Length of the data sent by the client.
98    ///
99    /// # Returns
100    ///
101    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
102    /// ohos.permission.INTERNET
103    ///
104    /// Required System Capabilities: SystemCapability.Communication.NetStack
105    ///
106    /// Available since API-level: 11
107    ///
108    /// Version: 1.0
109    #[cfg(feature = "api-11")]
110    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
111    pub fn OH_WebSocketClient_Send(
112        client: *mut WebSocket,
113        data: *mut ::core::ffi::c_char,
114        length: usize,
115    ) -> ::core::ffi::c_int;
116    /// Closes a webSocket connection.
117    ///
118    /// # Arguments
119    ///
120    /// * `client` - Pointer to the websocket client.
121    ///
122    /// * `options` - Optional parameters.
123    ///
124    /// # Returns
125    ///
126    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
127    /// ohos.permission.INTERNET
128    ///
129    /// Required System Capabilities: SystemCapability.Communication.NetStack
130    ///
131    /// Available since API-level: 11
132    ///
133    /// Version: 1.0
134    #[cfg(feature = "api-11")]
135    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
136    pub fn OH_WebSocketClient_Close(
137        client: *mut WebSocket,
138        options: WebSocket_CloseOption,
139    ) -> ::core::ffi::c_int;
140    /// Releases the context and resources of the websocket connection.
141    ///
142    /// # Arguments
143    ///
144    /// * `client` - Pointer to the websocket client.
145    ///
146    /// # Returns
147    ///
148    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
149    /// ohos.permission.INTERNET
150    ///
151    /// Required System Capabilities: SystemCapability.Communication.NetStack
152    ///
153    /// Available since API-level: 11
154    ///
155    /// Version: 1.0
156    #[cfg(feature = "api-11")]
157    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
158    pub fn OH_WebSocketClient_Destroy(client: *mut WebSocket) -> ::core::ffi::c_int;
159}