
---@class mqtt_connector_ngx*: mqtt_connector
---@type mqtt_connector_ngx*
local M = {}

--- Open the OpenResty cosocket network connection.
---@param conn mqtt_connection* Connection parameters and status.
---@return boolean ok Whether it is successful or not.
---@return string? errMsg error message.
function M.connect(conn) end

--- Close the network connection.
---@param conn mqtt_connection* Connection status.
function M.shutdown(conn) end

--- Send data.
---@param conn mqtt_connection* Connection status.
---@param data string data.
---@param i? integer starting position.
---@param j? integer end position.
---@return integer|nil bytes Number of bytes sent.
---@return string? errMsg error message.
function M.send(conn, data, i, j) end

--- Receive data of specified length.
---@param conn mqtt_connection* Connection status.
---@param size integer Number of bytes.
---@return string|nil data data.
---@return string? errMsg error message.
function M.receive(conn, size) end

--- Set timeout.
---@param conn mqtt_connection* Connection status.
---@param timeout? number Timeout time in seconds.
function M.settimeout(conn, timeout) end

return M
