Add subscription to multiple topics
This commit is contained in:
parent
57f0304d35
commit
3c00a7b81d
|
@ -22,7 +22,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
use crate::packet::publish_packet::QualityOfService;
|
||||
use crate::utils::types::{BinaryData, EncodedString};
|
||||
|
||||
|
@ -31,7 +30,7 @@ pub struct ClientConfig<'a> {
|
|||
pub username_flag: bool,
|
||||
pub username: EncodedString<'a>,
|
||||
pub password_flag: bool,
|
||||
pub password: BinaryData<'a>
|
||||
pub password: BinaryData<'a>,
|
||||
}
|
||||
|
||||
impl ClientConfig<'a> {
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
use rand_core::RngCore;
|
||||
use crate::client::client_config::ClientConfig;
|
||||
use crate::network::network_trait::{Network};
|
||||
use crate::network::network_trait::Network;
|
||||
use crate::packet::connack_packet::ConnackPacket;
|
||||
use crate::packet::connect_packet::ConnectPacket;
|
||||
use crate::packet::disconnect_packet::DisconnectPacket;
|
||||
use crate::packet::mqtt_packet::Packet;
|
||||
use crate::packet::pingreq_packet::PingreqPacket;
|
||||
use crate::packet::pingresp_packet::PingrespPacket;
|
||||
use crate::packet::puback_packet::PubackPacket;
|
||||
use crate::packet::publish_packet::{PublishPacket, QualityOfService};
|
||||
use crate::packet::publish_packet::QualityOfService::QoS1;
|
||||
use crate::packet::publish_packet::{PublishPacket, QualityOfService};
|
||||
use crate::packet::reason_codes::ReasonCode;
|
||||
use crate::packet::suback_packet::SubackPacket;
|
||||
use crate::packet::subscription_packet::SubscriptionPacket;
|
||||
use crate::utils::buffer_reader::BuffReader;
|
||||
use crate::utils::rng_generator::CountingRng;
|
||||
use crate::utils::types::BufferError;
|
||||
use heapless::Vec;
|
||||
use rand_core::RngCore;
|
||||
|
||||
pub struct MqttClientV5<'a, T, const MAX_PROPERTIES: usize> {
|
||||
network_driver: &'a mut T,
|
||||
|
@ -29,7 +32,14 @@ impl<'a, T, const MAX_PROPERTIES: usize> MqttClientV5<'a, T, MAX_PROPERTIES>
|
|||
where
|
||||
T: Network,
|
||||
{
|
||||
pub fn new(network_driver: &'a mut T, buffer: &'a mut [u8], buffer_len: usize, recv_buffer: &'a mut [u8], recv_buffer_len: usize, config: ClientConfig<'a>) -> Self {
|
||||
pub fn new(
|
||||
network_driver: &'a mut T,
|
||||
buffer: &'a mut [u8],
|
||||
buffer_len: usize,
|
||||
recv_buffer: &'a mut [u8],
|
||||
recv_buffer_len: usize,
|
||||
config: ClientConfig<'a>,
|
||||
) -> Self {
|
||||
Self {
|
||||
network_driver,
|
||||
buffer,
|
||||
|
@ -37,7 +47,7 @@ where
|
|||
recv_buffer,
|
||||
recv_buffer_len,
|
||||
rng: CountingRng(50),
|
||||
config
|
||||
config,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +90,6 @@ where
|
|||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub async fn disconnect<'b>(&'b mut self) -> Result<(), ReasonCode> {
|
||||
|
@ -99,7 +108,6 @@ where
|
|||
topic_name: &'b str,
|
||||
message: &'b str,
|
||||
) -> Result<(), ReasonCode> {
|
||||
|
||||
let identifier: u16 = self.rng.next_u32() as u16;
|
||||
let len = {
|
||||
let mut packet = PublishPacket::<'b, 5>::new();
|
||||
|
@ -117,13 +125,15 @@ where
|
|||
|
||||
self.network_driver.send(self.buffer, len.unwrap()).await?;
|
||||
|
||||
|
||||
//QoS1
|
||||
if <QualityOfService as Into<u8>>::into(self.config.qos ) == <QualityOfService as Into<u8>>::into(QoS1) {
|
||||
if <QualityOfService as Into<u8>>::into(self.config.qos)
|
||||
== <QualityOfService as Into<u8>>::into(QoS1)
|
||||
{
|
||||
let reason: Result<[u16; 2], BufferError> = {
|
||||
self.network_driver.receive(self.buffer).await?;
|
||||
let mut packet = PubackPacket::<'b, 5>::new();
|
||||
if let Err(err) = packet.decode(&mut BuffReader::new(self.buffer, self.buffer_len)) {
|
||||
if let Err(err) = packet.decode(&mut BuffReader::new(self.buffer, self.buffer_len))
|
||||
{
|
||||
Err(err)
|
||||
} else {
|
||||
Ok([packet.packet_identifier, packet.reason_code as u16])
|
||||
|
@ -147,9 +157,63 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// TODO - multiple topic subscribe func
|
||||
pub async fn subscribe_to_topics<'b, const TOPICS: usize>(
|
||||
&'b mut self,
|
||||
topic_names: &'b Vec<&'b str, TOPICS>,
|
||||
) -> Result<(), ReasonCode> {
|
||||
let len = {
|
||||
let mut subs = SubscriptionPacket::<'b, TOPICS, 1>::new();
|
||||
let mut i = 0;
|
||||
loop {
|
||||
if i == TOPICS {
|
||||
break;
|
||||
}
|
||||
subs.add_new_filter(topic_names.get(i).unwrap(), self.config.qos);
|
||||
i = i + 1;
|
||||
}
|
||||
subs.encode(self.buffer, self.buffer_len)
|
||||
};
|
||||
|
||||
pub async fn subscribe_to_topic<'b>(&'b mut self, topic_name: &'b str) -> Result<(), ReasonCode> {
|
||||
if let Err(err) = len {
|
||||
log::error!("[DECODE ERR]: {}", err);
|
||||
return Err(ReasonCode::BuffError);
|
||||
}
|
||||
|
||||
self.network_driver.send(self.buffer, len.unwrap()).await?;
|
||||
|
||||
let reason: Result<Vec<u8, TOPICS>, BufferError> = {
|
||||
self.network_driver.receive(self.buffer).await?;
|
||||
|
||||
let mut packet = SubackPacket::<'b, TOPICS, 5>::new();
|
||||
if let Err(err) = packet.decode(&mut BuffReader::new(self.buffer, self.buffer_len)) {
|
||||
Err(err)
|
||||
} else {
|
||||
Ok(packet.reason_codes)
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(err) = reason {
|
||||
log::error!("[DECODE ERR]: {}", err);
|
||||
return Err(ReasonCode::BuffError);
|
||||
}
|
||||
let reasons = reason.unwrap();
|
||||
let mut i = 0;
|
||||
loop {
|
||||
if i == TOPICS {
|
||||
break;
|
||||
}
|
||||
if *reasons.get(i).unwrap() != self.config.qos.into() {
|
||||
return Err(ReasonCode::from(*reasons.get(i).unwrap()));
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn subscribe_to_topic<'b>(
|
||||
&'b mut self,
|
||||
topic_name: &'b str,
|
||||
) -> Result<(), ReasonCode> {
|
||||
let len = {
|
||||
let mut subs = SubscriptionPacket::<'b, 1, 1>::new();
|
||||
subs.add_new_filter(topic_name, self.config.qos);
|
||||
|
@ -185,18 +249,21 @@ where
|
|||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub async fn receive_message<'b>(&'b mut self) -> Result<&'b [u8], ReasonCode> {
|
||||
self.network_driver.receive(self.recv_buffer).await?;
|
||||
let mut packet = PublishPacket::<'b, 5>::new();
|
||||
if let Err(err) = packet.decode(&mut BuffReader::new(self.recv_buffer, self.recv_buffer_len)) {
|
||||
if let Err(err) =
|
||||
packet.decode(&mut BuffReader::new(self.recv_buffer, self.recv_buffer_len))
|
||||
{
|
||||
log::error!("[DECODE ERR]: {}", err);
|
||||
return Err(ReasonCode::BuffError);
|
||||
}
|
||||
|
||||
if (packet.fixed_header & 0x06) == <QualityOfService as Into<u8>>::into(QualityOfService::QoS1) {
|
||||
if (packet.fixed_header & 0x06)
|
||||
== <QualityOfService as Into<u8>>::into(QualityOfService::QoS1)
|
||||
{
|
||||
let mut puback = PubackPacket::<'b, 5>::new();
|
||||
puback.packet_identifier = packet.packet_identifier;
|
||||
puback.reason_code = 0x00;
|
||||
|
@ -212,4 +279,27 @@ where
|
|||
|
||||
return Ok(packet.message.unwrap());
|
||||
}
|
||||
|
||||
pub async fn send_ping<'b>(&'b mut self) -> Result<(), ReasonCode> {
|
||||
let len = {
|
||||
let mut packet = PingreqPacket::new();
|
||||
packet.encode(self.buffer, self.buffer_len)
|
||||
};
|
||||
|
||||
if let Err(err) = len {
|
||||
log::error!("[DECODE ERR]: {}", err);
|
||||
return Err(ReasonCode::BuffError);
|
||||
}
|
||||
|
||||
self.network_driver.send(self.buffer, len.unwrap()).await?;
|
||||
|
||||
self.network_driver.receive(self.buffer).await?;
|
||||
let mut packet = PingrespPacket::new();
|
||||
if let Err(err) = packet.decode(&mut BuffReader::new(self.buffer, self.buffer_len)) {
|
||||
log::error!("[DECODE ERR]: {}", err);
|
||||
return Err(ReasonCode::BuffError);
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,5 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
pub mod client_v5;
|
||||
pub mod client_config;
|
||||
pub mod client_v5;
|
||||
|
|
|
@ -22,5 +22,4 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
pub mod variable_byte_integer;
|
||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -1,15 +1,17 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use tokio::{join, task};
|
||||
use heapless::Vec;
|
||||
|
||||
use tokio::time::sleep;
|
||||
use tokio::{join, task};
|
||||
|
||||
use rust_mqtt::client::client_config::ClientConfig;
|
||||
use rust_mqtt::client::client_v5::MqttClientV5;
|
||||
use rust_mqtt::network::network_trait::{Network, NetworkError};
|
||||
use rust_mqtt::packet::connect_packet::ConnectPacket;
|
||||
use rust_mqtt::packet::mqtt_packet::Packet;
|
||||
use rust_mqtt::packet::publish_packet::{PublishPacket, QualityOfService};
|
||||
use rust_mqtt::packet::publish_packet::QualityOfService::QoS1;
|
||||
use rust_mqtt::packet::publish_packet::{PublishPacket, QualityOfService};
|
||||
use rust_mqtt::packet::subscription_packet::SubscriptionPacket;
|
||||
use rust_mqtt::tokio_network::TokioNetwork;
|
||||
|
||||
|
@ -21,27 +23,49 @@ async fn receive() {
|
|||
let mut config = ClientConfig::new();
|
||||
config.add_qos(QualityOfService::QoS1);
|
||||
config.add_username("test");
|
||||
config.add_password("testPass1");
|
||||
config.add_password("testPass");
|
||||
let mut res2 = vec![0; 260];
|
||||
let mut res3 = vec![0; 260];
|
||||
let mut client = MqttClientV5::<TokioNetwork, 5>::new(&mut tokio_network, &mut res2, 260, & mut res3, 260, config);
|
||||
let mut client = MqttClientV5::<TokioNetwork, 5>::new(
|
||||
&mut tokio_network,
|
||||
&mut res2,
|
||||
260,
|
||||
&mut res3,
|
||||
260,
|
||||
config,
|
||||
);
|
||||
|
||||
let mut result = {
|
||||
client.connect_to_broker().await
|
||||
};
|
||||
let mut result = { client.connect_to_broker().await };
|
||||
if let Err(r) = result {
|
||||
log::error!("[ERROR]: {}", r);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
client.subscribe_to_topic("test/topic").await;
|
||||
const TOPICS: usize = 2;
|
||||
let t1 = "test/topic1";
|
||||
let t2 = "test/topic2";
|
||||
let mut names = Vec::<&str, TOPICS>::new();
|
||||
names.push(&t1);
|
||||
names.push(&t2);
|
||||
client.subscribe_to_topics::<TOPICS>(&names).await;
|
||||
//client.subscribe_to_topic("test/topic").await;
|
||||
};
|
||||
|
||||
{
|
||||
sleep(Duration::from_secs(10));
|
||||
client.send_ping().await;
|
||||
}
|
||||
let mut o = 0;
|
||||
loop {
|
||||
if o == 2 {
|
||||
break;
|
||||
}
|
||||
log::info!("Waiting for new message!");
|
||||
let mes = client.receive_message().await.unwrap();
|
||||
let x = String::from_utf8_lossy(mes);
|
||||
log::info!("Got new message: {}", x);
|
||||
o = o + 1;
|
||||
}
|
||||
{
|
||||
client.disconnect().await;
|
||||
|
@ -56,22 +80,30 @@ async fn publish(message: &str) {
|
|||
let config = ClientConfig::new();
|
||||
let mut res2 = vec![0; 260];
|
||||
let mut res3 = vec![0; 260];
|
||||
let mut client = MqttClientV5::<TokioNetwork, 5>::new(&mut tokio_network, &mut res2, 260, & mut res3, 260, config);
|
||||
let mut client = MqttClientV5::<TokioNetwork, 5>::new(
|
||||
&mut tokio_network,
|
||||
&mut res2,
|
||||
260,
|
||||
&mut res3,
|
||||
260,
|
||||
config,
|
||||
);
|
||||
|
||||
let mut result = { client.connect_to_broker().await };
|
||||
log::info!("Waiting until send!");
|
||||
sleep(Duration::from_secs(15));
|
||||
result = {
|
||||
log::info!("Sending new message!");
|
||||
client
|
||||
/*client
|
||||
.send_message("test/topic", message)
|
||||
.await
|
||||
.await*/
|
||||
client.send_ping().await
|
||||
};
|
||||
if let Err(e) = result {
|
||||
log::error!("Chyba!");
|
||||
}
|
||||
|
||||
result = {
|
||||
/*result = {
|
||||
log::info!("Sending new message!");
|
||||
client
|
||||
.send_message("test/topic", "Dalsi zprava :)")
|
||||
|
@ -79,7 +111,7 @@ async fn publish(message: &str) {
|
|||
};
|
||||
if let Err(err) = result {
|
||||
log::error!("Chyba!");
|
||||
}
|
||||
}*/
|
||||
|
||||
{
|
||||
client.disconnect().await;
|
||||
|
@ -103,6 +135,7 @@ async fn main() {
|
|||
|
||||
join!(recv, publ);*/
|
||||
receive().await;
|
||||
|
||||
//publish("Ahoj 123").await;
|
||||
log::info!("Done");
|
||||
}
|
||||
|
|
|
@ -22,5 +22,4 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
pub mod network_trait;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
use heapless::Vec;
|
||||
|
||||
use crate::encoding::variable_byte_integer::VariableByteIntegerEncoder;
|
||||
|
@ -69,7 +68,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for AuthPacket<'a, MAX_PROPERTI
|
|||
remain_len: 0,
|
||||
auth_reason: 0x00,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new()
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,8 +76,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for AuthPacket<'a, MAX_PROPERTI
|
|||
let mut buff_writer = BuffWriter::new(buffer, buff_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
rm_ln = rm_ln + property_len_len as u32;
|
||||
rm_ln = rm_ln + 1;
|
||||
|
|
|
@ -43,7 +43,10 @@ pub struct ConnackPacket<'a, const MAX_PROPERTIES: usize> {
|
|||
}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> ConnackPacket<'a, MAX_PROPERTIES> {
|
||||
pub fn decode_connack_packet(&mut self, buff_reader: &mut BuffReader<'a>) -> Result<(), BufferError> {
|
||||
pub fn decode_connack_packet(
|
||||
&mut self,
|
||||
buff_reader: &mut BuffReader<'a>,
|
||||
) -> Result<(), BufferError> {
|
||||
if self.decode_fixed_header(buff_reader)? != (PacketType::Connack).into() {
|
||||
log::error!("Packet you are trying to decode is not CONNACK packet!");
|
||||
return Err(BufferError::PacketTypeMismatch);
|
||||
|
|
|
@ -128,15 +128,13 @@ impl<'a, const MAX_PROPERTIES: usize, const MAX_WILL_PROPERTIES: usize> Packet<'
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
// Number 12 => protocol_name_len + protocol_name + protocol_version + connect_flags + keep_alive + client_id_len
|
||||
rm_ln = rm_ln + property_len_len as u32 + 12;
|
||||
|
||||
if self.connect_flags & 0x04 != 0 {
|
||||
let wil_prop_len_enc =
|
||||
VariableByteIntegerEncoder::encode(self.will_property_len) ?;
|
||||
let wil_prop_len_enc = VariableByteIntegerEncoder::encode(self.will_property_len)?;
|
||||
let wil_prop_len_len = VariableByteIntegerEncoder::len(wil_prop_len_enc);
|
||||
rm_ln = rm_ln
|
||||
+ wil_prop_len_len as u32
|
||||
|
|
|
@ -47,7 +47,6 @@ pub struct DisconnectPacket<'a, const MAX_PROPERTIES: usize> {
|
|||
}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> DisconnectPacket<'a, MAX_PROPERTIES> {
|
||||
|
||||
fn add_reason(&mut self, reason: u8) {
|
||||
self.disconnect_reason = reason;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ pub mod connect_packet;
|
|||
pub mod disconnect_packet;
|
||||
pub mod pingreq_packet;
|
||||
pub mod pingresp_packet;
|
||||
pub mod reason_codes;
|
||||
pub mod suback_packet;
|
||||
pub mod unsuback_packet;
|
||||
pub mod reason_codes;
|
||||
|
|
|
@ -71,7 +71,10 @@ pub trait Packet<'a> {
|
|||
}
|
||||
|
||||
/// Method is decoding packet header into fixed header part and remaining length
|
||||
fn decode_fixed_header(&mut self, buff_reader: &mut BuffReader) -> Result<PacketType, BufferError> {
|
||||
fn decode_fixed_header(
|
||||
&mut self,
|
||||
buff_reader: &mut BuffReader,
|
||||
) -> Result<PacketType, BufferError> {
|
||||
let first_byte: u8 = buff_reader.read_u8()?;
|
||||
self.set_fixed_header(first_byte);
|
||||
self.set_remaining_len(buff_reader.read_variable_byte_int()?);
|
||||
|
|
|
@ -41,7 +41,7 @@ impl<'a> Packet<'a> for PingreqPacket {
|
|||
fn new() -> Self {
|
||||
Self {
|
||||
fixed_header: PacketType::Pingreq.into(),
|
||||
remain_len: 0
|
||||
remain_len: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,14 +35,13 @@ pub struct PingrespPacket {
|
|||
pub remain_len: u32,
|
||||
}
|
||||
|
||||
impl<'a> PingrespPacket {
|
||||
}
|
||||
impl<'a> PingrespPacket {}
|
||||
|
||||
impl<'a> Packet<'a> for PingrespPacket {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
fixed_header: PacketType::Pingresp.into(),
|
||||
remain_len: 0
|
||||
remain_len: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,8 @@ impl<'a> Packet<'a> for PingrespPacket {
|
|||
}
|
||||
|
||||
fn decode(&mut self, buff_reader: &mut BuffReader<'a>) -> Result<(), BufferError> {
|
||||
if self.decode_fixed_header(buff_reader) ? != (PacketType::Pingresp).into() {
|
||||
let x = self.decode_fixed_header(buff_reader)?;
|
||||
if x != (PacketType::Pingresp).into() {
|
||||
log::error!("Packet you are trying to decode is not PINGRESP packet!");
|
||||
return Err(BufferError::PacketTypeMismatch);
|
||||
}
|
||||
|
|
|
@ -42,9 +42,7 @@ pub struct PubackPacket<'a, const MAX_PROPERTIES: usize> {
|
|||
pub properties: Vec<Property<'a>, MAX_PROPERTIES>,
|
||||
}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubackPacket<'a, MAX_PROPERTIES> {
|
||||
|
||||
}
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubackPacket<'a, MAX_PROPERTIES> {}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubackPacket<'a, MAX_PROPERTIES> {
|
||||
fn new() -> Self {
|
||||
|
@ -54,7 +52,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubackPacket<'a, MAX_PROPER
|
|||
packet_identifier: 0,
|
||||
reason_code: 0,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new()
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +60,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubackPacket<'a, MAX_PROPER
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
rm_ln = rm_ln + property_len_len as u32 + 3;
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ pub struct PubcompPacket<'a, const MAX_PROPERTIES: usize> {
|
|||
pub properties: Vec<Property<'a>, MAX_PROPERTIES>,
|
||||
}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubcompPacket<'a, MAX_PROPERTIES> {
|
||||
}
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubcompPacket<'a, MAX_PROPERTIES> {}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubcompPacket<'a, MAX_PROPERTIES> {
|
||||
fn new() -> Self {
|
||||
|
@ -53,7 +52,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubcompPacket<'a, MAX_PROPE
|
|||
packet_identifier: 0,
|
||||
reason_code: 0,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new()
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +60,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubcompPacket<'a, MAX_PROPE
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
rm_ln = rm_ln + property_len_len as u32 + 3;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ use heapless::Vec;
|
|||
|
||||
use crate::encoding::variable_byte_integer::VariableByteIntegerEncoder;
|
||||
use crate::packet::mqtt_packet::Packet;
|
||||
use crate::packet::publish_packet::QualityOfService::{INVALID, QoS0, QoS1, QoS2};
|
||||
use crate::packet::publish_packet::QualityOfService::{QoS0, QoS1, QoS2, INVALID};
|
||||
use crate::utils::buffer_reader::BuffReader;
|
||||
use crate::utils::buffer_writer::BuffWriter;
|
||||
use crate::utils::types::{BufferError, EncodedString};
|
||||
|
@ -102,7 +102,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PublishPacket<'a, MAX_PROPE
|
|||
packet_identifier: 1,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
message: None
|
||||
message: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PublishPacket<'a, MAX_PROPE
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
let msg_len = self.message.unwrap().len() as u32;
|
||||
rm_ln = rm_ln + property_len_len as u32 + msg_len + self.topic_name.len as u32 + 2;
|
||||
|
@ -147,8 +146,8 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PublishPacket<'a, MAX_PROPE
|
|||
self.packet_identifier = buff_reader.read_u16()?;
|
||||
}
|
||||
self.decode_properties(buff_reader)?;
|
||||
let mut total_len = VariableByteIntegerEncoder::len(
|
||||
VariableByteIntegerEncoder::encode(self.remain_len) ?);
|
||||
let mut total_len =
|
||||
VariableByteIntegerEncoder::len(VariableByteIntegerEncoder::encode(self.remain_len)?);
|
||||
total_len = total_len + 1 + self.remain_len as usize;
|
||||
self.message = Some(buff_reader.read_message(total_len));
|
||||
Ok(())
|
||||
|
|
|
@ -42,8 +42,7 @@ pub struct PubrecPacket<'a, const MAX_PROPERTIES: usize> {
|
|||
pub properties: Vec<Property<'a>, MAX_PROPERTIES>,
|
||||
}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubrecPacket<'a, MAX_PROPERTIES> {
|
||||
}
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubrecPacket<'a, MAX_PROPERTIES> {}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubrecPacket<'a, MAX_PROPERTIES> {
|
||||
fn new() -> Self {
|
||||
|
@ -53,7 +52,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubrecPacket<'a, MAX_PROPER
|
|||
packet_identifier: 0,
|
||||
reason_code: 0,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new()
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +60,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubrecPacket<'a, MAX_PROPER
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
rm_ln = rm_ln + property_len_len as u32 + 3;
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ pub struct PubrelPacket<'a, const MAX_PROPERTIES: usize> {
|
|||
pub properties: Vec<Property<'a>, MAX_PROPERTIES>,
|
||||
}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubrelPacket<'a, MAX_PROPERTIES> {
|
||||
}
|
||||
impl<'a, const MAX_PROPERTIES: usize> PubrelPacket<'a, MAX_PROPERTIES> {}
|
||||
|
||||
impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubrelPacket<'a, MAX_PROPERTIES> {
|
||||
fn new() -> Self {
|
||||
|
@ -53,7 +52,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubrelPacket<'a, MAX_PROPER
|
|||
packet_identifier: 0,
|
||||
reason_code: 0,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new()
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +60,7 @@ impl<'a, const MAX_PROPERTIES: usize> Packet<'a> for PubrelPacket<'a, MAX_PROPER
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
rm_ln = rm_ln + property_len_len as u32 + 3;
|
||||
|
||||
|
|
|
@ -96,9 +96,8 @@ impl Into<u8> for ReasonCode {
|
|||
ReasonCode::SubscriptionIdentifiersNotSupported => 0xA1,
|
||||
ReasonCode::WildcardSubscriptionNotSupported => 0xA2,
|
||||
ReasonCode::BuffError => 0xFE,
|
||||
ReasonCode::NetworkError => 0xFF
|
||||
}
|
||||
|
||||
ReasonCode::NetworkError => 0xFF,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,8 +147,8 @@ impl From<u8> for ReasonCode {
|
|||
0xA1 => ReasonCode::SubscriptionIdentifiersNotSupported,
|
||||
0xA2 => ReasonCode::WildcardSubscriptionNotSupported,
|
||||
0xFE => ReasonCode::BuffError,
|
||||
_ => ReasonCode::NetworkError
|
||||
}
|
||||
_ => ReasonCode::NetworkError,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +169,9 @@ impl Display for ReasonCode {
|
|||
ReasonCode::ImplementationSpecificError => write!(f, "Implementation specific error!"),
|
||||
ReasonCode::UnsupportedProtocolVersion => write!(f, "Unsupported protocol version!"),
|
||||
ReasonCode::ClientIdNotValid => write!(f, "Client sent not valid identification"),
|
||||
ReasonCode::BadUserNameOrPassword => write!(f, "Authentication error, username of password not valid!"),
|
||||
ReasonCode::BadUserNameOrPassword => {
|
||||
write!(f, "Authentication error, username of password not valid!")
|
||||
}
|
||||
ReasonCode::NotAuthorized => write!(f, "Client not authorized!"),
|
||||
ReasonCode::ServerUnavailable => write!(f, "Server unavailable!"),
|
||||
ReasonCode::ServerBusy => write!(f, "Server is busy!"),
|
||||
|
@ -194,11 +195,17 @@ impl Display for ReasonCode {
|
|||
ReasonCode::QoSNotSupported => write!(f, "Used QoS is not supported!"),
|
||||
ReasonCode::UseAnotherServer => write!(f, "Use another server!"),
|
||||
ReasonCode::ServerMoved => write!(f, "Server moved!"),
|
||||
ReasonCode::SharedSubscriptionNotSupported => write!(f, "Shared subscription is not supported"),
|
||||
ReasonCode::SharedSubscriptionNotSupported => {
|
||||
write!(f, "Shared subscription is not supported")
|
||||
}
|
||||
ReasonCode::ConnectionRateExceeded => write!(f, "Connection rate exceeded!"),
|
||||
ReasonCode::MaximumConnectTime => write!(f, "Maximum connect time exceeded!"),
|
||||
ReasonCode::SubscriptionIdentifiersNotSupported => write!(f, "Subscription identifier not supported!"),
|
||||
ReasonCode::WildcardSubscriptionNotSupported => write!(f, "Wildcard subscription not supported!"),
|
||||
ReasonCode::SubscriptionIdentifiersNotSupported => {
|
||||
write!(f, "Subscription identifier not supported!")
|
||||
}
|
||||
ReasonCode::WildcardSubscriptionNotSupported => {
|
||||
write!(f, "Wildcard subscription not supported!")
|
||||
}
|
||||
ReasonCode::BuffError => write!(f, "Error encountered during write / read from packet"),
|
||||
ReasonCode::NetworkError => write!(f, "Unknown error!"),
|
||||
}
|
||||
|
|
|
@ -43,7 +43,10 @@ pub struct SubackPacket<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: usiz
|
|||
impl<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: usize>
|
||||
SubackPacket<'a, MAX_REASONS, MAX_PROPERTIES>
|
||||
{
|
||||
pub fn read_reason_codes(&mut self, buff_reader: &mut BuffReader<'a>) -> Result<(), BufferError> {
|
||||
pub fn read_reason_codes(
|
||||
&mut self,
|
||||
buff_reader: &mut BuffReader<'a>,
|
||||
) -> Result<(), BufferError> {
|
||||
let mut i = 0;
|
||||
loop {
|
||||
self.reason_codes.push(buff_reader.read_u8()?);
|
||||
|
@ -52,7 +55,7 @@ impl<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: usize>
|
|||
break;
|
||||
}
|
||||
}
|
||||
return Ok(())
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,13 +69,13 @@ impl<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: usize> Packet<'a>
|
|||
packet_identifier: 0,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
reason_codes: Vec::<u8, MAX_REASONS>::new()
|
||||
reason_codes: Vec::<u8, MAX_REASONS>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn encode(&mut self, _buffer: &mut [u8], _buffer_len: usize) -> Result<usize, BufferError> {
|
||||
log::error!("SUBACK packet does not support encoding!");
|
||||
return Err(BufferError::WrongPacketToEncode)
|
||||
return Err(BufferError::WrongPacketToEncode);
|
||||
}
|
||||
|
||||
fn decode(&mut self, buff_reader: &mut BuffReader<'a>) -> Result<(), BufferError> {
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
|
||||
use heapless::Vec;
|
||||
|
||||
use super::packet_type::PacketType;
|
||||
use super::property::Property;
|
||||
use crate::encoding::variable_byte_integer::VariableByteIntegerEncoder;
|
||||
use crate::packet::mqtt_packet::Packet;
|
||||
use crate::packet::publish_packet::QualityOfService;
|
||||
use crate::utils::buffer_reader::BuffReader;
|
||||
use crate::utils::buffer_writer::BuffWriter;
|
||||
use crate::utils::types::{BufferError, TopicFilter};
|
||||
use super::packet_type::PacketType;
|
||||
use super::property::Property;
|
||||
|
||||
pub struct SubscriptionPacket<'a, const MAX_FILTERS: usize, const MAX_PROPERTIES: usize> {
|
||||
pub fixed_header: u8,
|
||||
|
@ -51,7 +51,8 @@ impl<'a, const MAX_FILTERS: usize, const MAX_PROPERTIES: usize>
|
|||
let mut new_filter = TopicFilter::new();
|
||||
new_filter.filter.string = topic_name;
|
||||
new_filter.filter.len = len as u16;
|
||||
new_filter.sub_options = new_filter.sub_options | (<QualityOfService as Into<u8>>::into(qos) >> 1);
|
||||
new_filter.sub_options =
|
||||
new_filter.sub_options | (<QualityOfService as Into<u8>>::into(qos) >> 1);
|
||||
self.topic_filters.push(new_filter);
|
||||
self.topic_filter_len = self.topic_filter_len + 1;
|
||||
}
|
||||
|
@ -77,8 +78,7 @@ impl<'a, const MAX_FILTERS: usize, const MAX_PROPERTIES: usize> Packet<'a>
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
|
||||
let mut lt = 0;
|
||||
|
|
|
@ -43,7 +43,10 @@ pub struct UnsubackPacket<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: us
|
|||
impl<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: usize>
|
||||
UnsubackPacket<'a, MAX_REASONS, MAX_PROPERTIES>
|
||||
{
|
||||
pub fn read_reason_codes(&mut self, buff_reader: &mut BuffReader<'a>) -> Result<(), BufferError> {
|
||||
pub fn read_reason_codes(
|
||||
&mut self,
|
||||
buff_reader: &mut BuffReader<'a>,
|
||||
) -> Result<(), BufferError> {
|
||||
let mut i = 0;
|
||||
loop {
|
||||
self.reason_codes.push(buff_reader.read_u8()?);
|
||||
|
@ -66,7 +69,7 @@ impl<'a, const MAX_REASONS: usize, const MAX_PROPERTIES: usize> Packet<'a>
|
|||
packet_identifier: 0,
|
||||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
reason_codes: Vec::<u8, MAX_REASONS>::new()
|
||||
reason_codes: Vec::<u8, MAX_REASONS>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ impl<'a, const MAX_FILTERS: usize, const MAX_PROPERTIES: usize> Packet<'a>
|
|||
property_len: 0,
|
||||
properties: Vec::<Property<'a>, MAX_PROPERTIES>::new(),
|
||||
topic_filter_len: 0,
|
||||
topic_filters: Vec::<TopicFilter<'a>, MAX_FILTERS>::new()
|
||||
topic_filters: Vec::<TopicFilter<'a>, MAX_FILTERS>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,7 @@ impl<'a, const MAX_FILTERS: usize, const MAX_PROPERTIES: usize> Packet<'a>
|
|||
let mut buff_writer = BuffWriter::new(buffer, buffer_len);
|
||||
|
||||
let mut rm_ln = self.property_len;
|
||||
let property_len_enc: [u8; 4] =
|
||||
VariableByteIntegerEncoder::encode(self.property_len) ?;
|
||||
let property_len_enc: [u8; 4] = VariableByteIntegerEncoder::encode(self.property_len)?;
|
||||
let property_len_len = VariableByteIntegerEncoder::len(property_len_enc);
|
||||
rm_ln = rm_ln + property_len_len as u32 + 4 + self.topic_filter_len as u32;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl<'a> BuffReader<'a> {
|
|||
return BuffReader {
|
||||
buffer,
|
||||
position: 0,
|
||||
len: buff_len
|
||||
len: buff_len,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ impl<'a> BuffReader<'a> {
|
|||
let len = self.read_u16();
|
||||
match len {
|
||||
Err(err) => return Err(err),
|
||||
_ => {},
|
||||
_ => {}
|
||||
}
|
||||
let len_res = len.unwrap();
|
||||
let res_str =
|
||||
|
@ -147,7 +147,6 @@ impl<'a> BuffReader<'a> {
|
|||
|
||||
/// Read payload message from buffer
|
||||
pub fn read_message(&mut self, total_len: usize) -> &'a [u8] {
|
||||
|
||||
if total_len > self.len {
|
||||
return &self.buffer[self.position..self.len];
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ use heapless::Vec;
|
|||
|
||||
use crate::encoding::variable_byte_integer::{VariableByteInteger, VariableByteIntegerEncoder};
|
||||
use crate::packet::property::Property;
|
||||
use crate::utils::types::{BinaryData, EncodedString, StringPair, BufferError, TopicFilter};
|
||||
use crate::utils::types::{BinaryData, BufferError, EncodedString, StringPair, TopicFilter};
|
||||
|
||||
pub struct BuffWriter<'a> {
|
||||
buffer: &'a mut [u8],
|
||||
pub position: usize,
|
||||
len: usize
|
||||
len: usize,
|
||||
}
|
||||
|
||||
impl<'a> BuffWriter<'a> {
|
||||
|
@ -39,7 +39,7 @@ impl<'a> BuffWriter<'a> {
|
|||
return BuffWriter {
|
||||
buffer,
|
||||
position: 0,
|
||||
len: buff_len
|
||||
len: buff_len,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,7 @@ impl<'a> BuffWriter<'a> {
|
|||
self.buffer[self.position] = byte;
|
||||
self.increment_position(1);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
pub fn write_u16(&mut self, two_bytes: u16) -> Result<(), BufferError> {
|
||||
|
@ -130,7 +129,10 @@ impl<'a> BuffWriter<'a> {
|
|||
return property.encode(self);
|
||||
}
|
||||
|
||||
pub fn encode_properties<const LEN: usize>(&mut self, properties: &Vec<Property<'a>, LEN>) -> Result<(), BufferError> {
|
||||
pub fn encode_properties<const LEN: usize>(
|
||||
&mut self,
|
||||
properties: &Vec<Property<'a>, LEN>,
|
||||
) -> Result<(), BufferError> {
|
||||
let mut i = 0;
|
||||
let len = properties.len();
|
||||
if len != 0 {
|
||||
|
@ -146,12 +148,16 @@ impl<'a> BuffWriter<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn encode_topic_filter_ref(&mut self, sub: bool, topic_filter: &TopicFilter<'a>) -> Result<(), BufferError> {
|
||||
fn encode_topic_filter_ref(
|
||||
&mut self,
|
||||
sub: bool,
|
||||
topic_filter: &TopicFilter<'a>,
|
||||
) -> Result<(), BufferError> {
|
||||
self.write_string_ref(&topic_filter.filter)?;
|
||||
if sub {
|
||||
self.write_u8(topic_filter.sub_options)?;
|
||||
}
|
||||
return Ok(())
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn encode_topic_filters_ref<const MAX: usize>(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// This code is handed from Embedded Rust documentation and
|
||||
// is accessible from https://docs.rust-embedded.org/cortex-m-rt/0.6.0/rand/trait.RngCore.html
|
||||
|
||||
use rand_core::{Error, impls, RngCore};
|
||||
use rand_core::{impls, Error, RngCore};
|
||||
|
||||
pub struct CountingRng(pub u64);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ pub enum BufferError {
|
|||
PacketTypeMismatch,
|
||||
WrongPacketToDecode,
|
||||
WrongPacketToEncode,
|
||||
PropertyNotFound
|
||||
PropertyNotFound,
|
||||
}
|
||||
|
||||
impl Display for BufferError {
|
||||
|
@ -55,8 +55,7 @@ impl Display for BufferError {
|
|||
}
|
||||
}
|
||||
/// Encoded string provides structure representing UTF-8 encoded string in MQTTv5 packets
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EncodedString<'a> {
|
||||
pub string: &'a str,
|
||||
pub len: u16,
|
||||
|
@ -73,8 +72,7 @@ impl EncodedString<'_> {
|
|||
}
|
||||
|
||||
/// Binary data represents `Binary data` in MQTTv5 protocol
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BinaryData<'a> {
|
||||
pub bin: &'a [u8],
|
||||
pub len: u16,
|
||||
|
|
Loading…
Reference in New Issue
Block a user