ohos-netstack-sys 0.1.0

Raw bindings to the OpenHarmony NetworkKit (netstack) native APIs
Documentation
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::net_websocket_type::*;

extern "C" {
    /// Constructor of websocket.
    ///
    /// # Arguments
    ///
    /// * `onOpen` - Callback function invoked when a connection setup message is received.
    ///
    /// * `onMessage` - Callback function invoked when a message is received.
    ///
    /// * `onError` - Callback function invoked when a connection error message is received.
    ///
    /// * `onclose` - Callback function invoked when a connection closing message is closed.
    ///
    ///
    /// # Returns
    ///
    /// * Pointer to the websocket client if success; NULL otherwise.
    ///
    /// Required System Capabilities: SystemCapability.Communication.NetStack
    ///
    /// Available since API-level: 11
    ///
    /// Version: 1.0
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_WebSocketClient_Constructor(
        onOpen: WebSocket_OnOpenCallback,
        onMessage: WebSocket_OnMessageCallback,
        onError: WebSocket_OnErrorCallback,
        onclose: WebSocket_OnCloseCallback,
    ) -> *mut WebSocket;
    /// Adds the header information to the client request.
    ///
    /// # Arguments
    ///
    /// * `client` - Pointer to the websocket client.
    ///
    /// * `header` - Header information
    ///
    /// # Returns
    ///
    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
    ///
    /// Required System Capabilities: SystemCapability.Communication.NetStack
    ///
    /// Available since API-level: 11
    ///
    /// Version: 1.0
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_WebSocketClient_AddHeader(
        client: *mut WebSocket,
        header: WebSocket_Header,
    ) -> ::core::ffi::c_int;
    /// Connects the client to the server.
    ///
    /// # Arguments
    ///
    /// * `client` - Pointer to the websocket client.
    ///
    /// * `url` - URL for the client to connect to the server.
    ///
    /// * `options` - Optional parameters.
    ///
    /// # Returns
    ///
    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
    /// ohos.permission.INTERNET
    ///
    /// Required System Capabilities: SystemCapability.Communication.NetStack
    ///
    /// Available since API-level: 11
    ///
    /// Version: 1.0
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_WebSocketClient_Connect(
        client: *mut WebSocket,
        url: *const ::core::ffi::c_char,
        options: WebSocket_RequestOptions,
    ) -> ::core::ffi::c_int;
    /// Sends data from the client to the server.
    ///
    /// # Arguments
    ///
    /// * `client` - Pointer to the websocket client.
    ///
    /// * `data` - Data sent by the client.
    ///
    /// * `length` - Length of the data sent by the client.
    ///
    /// # Returns
    ///
    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
    /// ohos.permission.INTERNET
    ///
    /// Required System Capabilities: SystemCapability.Communication.NetStack
    ///
    /// Available since API-level: 11
    ///
    /// Version: 1.0
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_WebSocketClient_Send(
        client: *mut WebSocket,
        data: *mut ::core::ffi::c_char,
        length: usize,
    ) -> ::core::ffi::c_int;
    /// Closes a webSocket connection.
    ///
    /// # Arguments
    ///
    /// * `client` - Pointer to the websocket client.
    ///
    /// * `options` - Optional parameters.
    ///
    /// # Returns
    ///
    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
    /// ohos.permission.INTERNET
    ///
    /// Required System Capabilities: SystemCapability.Communication.NetStack
    ///
    /// Available since API-level: 11
    ///
    /// Version: 1.0
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_WebSocketClient_Close(
        client: *mut WebSocket,
        options: WebSocket_CloseOption,
    ) -> ::core::ffi::c_int;
    /// Releases the context and resources of the websocket connection.
    ///
    /// # Arguments
    ///
    /// * `client` - Pointer to the websocket client.
    ///
    /// # Returns
    ///
    /// * 0 if success; non-0 otherwise. For details about error codes, see [`OH_Websocket_ErrCode`].
    /// ohos.permission.INTERNET
    ///
    /// Required System Capabilities: SystemCapability.Communication.NetStack
    ///
    /// Available since API-level: 11
    ///
    /// Version: 1.0
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_WebSocketClient_Destroy(client: *mut WebSocket) -> ::core::ffi::c_int;
}