struct Message
XuAPI
pub struct Message {
pub valid bool
pub payload string
pub retained bool
}用途
承载 valid、payload、retained 等属性的结构体。
公开字段
validbool- 字段(bool)
payloadstring- 字段(string)
retainedbool- 字段(bool)
#embedded/mqtt标准库包 `#embedded/mqtt`。
struct Messagepub struct Message {
pub valid bool
pub payload string
pub retained bool
}承载 valid、payload、retained 等属性的结构体。
valid boolpayload stringretained boolstruct Clientpub struct Client {
pub error int
pub received int
pub published int
pub retransmits int
}Mqtt 客户端会话实例,维护与服务端的连接并提供操作接口。
error intreceived intpublished intretransmits intcreatepub fn create(id string, command_topic string, will_topic string, now int) Client创建新的文件、目录或资源。
id stringcommand_topic stringwill_topic stringnow intClient — 该类型的值
(&Client) readypub fn (c &Client) ready() bool在 &Client 上执行 ready 操作。
c &ClientClient 实例;以只读借用传入,调用方仍持有实例。bool — 是否成立
(&Client) failedpub fn (c &Client) failed() bool在 &Client 上执行 failed 操作。
c &ClientClient 实例;以只读借用传入,调用方仍持有实例。bool — 是否成立
(&Client) can_publishpub fn (c &Client) can_publish() bool&Client 上的操作:执行 can publish 操作。
c &ClientClient 实例;以只读借用传入,调用方仍持有实例。bool — 是否成立
($&Client) publishpub fn (c $&Client) publish(topic &string, payload &string, retain bool) bool向指定的消息主题或频道广播发布消息。
c $&ClientClient 实例;以独占借用传入,方法可修改它,调用方仍持有实例。topic &stringpayload &stringretain boolbool — 是否成立
($&Client) feedpub fn (c $&Client) feed(bytes &string, now int) bool在 $&Client 上执行 feed 操作。
c $&ClientClient 实例;以独占借用传入,方法可修改它,调用方仍持有实例。bytes &stringnow intbool — 是否成立
($&Client) readpub fn (c $&Client) read() Message$&Client 上的操作:读出最多 max 字节。
c $&ClientClient 实例;以独占借用传入,方法可修改它,调用方仍持有实例。Message — 该类型的值
($&Client) pollpub fn (c $&Client) poll(now int) string在 $&Client 上执行 poll 操作。
c $&ClientClient 实例;以独占借用传入,方法可修改它,调用方仍持有实例。now intstring — 结果字符串
($&Client) resetpub fn (c $&Client) reset(id string, command_topic string, will_topic string, now int)$&Client 上的操作:清空内部状态,可再写入或读取。
c $&ClientClient 实例;以独占借用传入,方法可修改它,调用方仍持有实例。id stringcommand_topic stringwill_topic stringnow int不返回值。
const MAX_PACKETpub const MAX_PACKET = 2048常量 MAX_PACKET,定义了相关的协议或算法配置参数。
const MAX_PAYLOADpub const MAX_PAYLOAD = 768常量 MAX_PAYLOAD,定义了相关的协议或算法配置参数。