
---@class mqtt_connection*
---@field uri? string Original URI.
---@field host string hostname.
---@field port integer port.
---@field sock any The underlying socket.
---@field timeout? number timeout period.
---@field secure? boolean TLS or not.
---@field secure_params? table TLS parameter.
---@field ssl_module? string TLS module name.

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

--- Open the 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 nextIndex Next send location.
---@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 period.
function M.settimeout(conn, timeout) end

return M
