Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PartialEq for all types #237

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ crate::v5::properties::define_properties! {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901217")]
pub struct MAuth<'i> {
pub reason: AuthReasonCode,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/connack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ define_properties![
}
];

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901074")]
pub struct MConnack<'i> {
pub session_present: bool,
Expand Down
4 changes: 2 additions & 2 deletions mqtt-format/src/v5/packets/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::v5::write::WResult;
use crate::v5::write::WriteMqttPacket;
use crate::v5::MResult;

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct MConnect<'i> {
pub client_identifier: &'i str,
pub username: Option<&'i str>,
Expand Down Expand Up @@ -208,7 +208,7 @@ impl<'i> MConnect<'i> {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Will<'i> {
pub properties: ConnectWillProperties<'i>,
pub topic: &'i str,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/disconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ define_properties! {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901205")]
pub struct MDisconnect<'i> {
pub reason_code: DisconnectReasonCode,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/pingreq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::v5::write::WResult;
use crate::v5::write::WriteMqttPacket;
use crate::v5::MResult;

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901195")]
pub struct MPingreq;

Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/pingresp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::v5::write::WResult;
use crate::v5::write::WriteMqttPacket;
use crate::v5::MResult;

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901200")]
pub struct MPingresp;

Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/puback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define_properties!(
}
);

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901121")]
pub struct MPuback<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/pubcomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ crate::v5::properties::define_properties! {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901151")]
pub struct MPubcomp<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::v5::write::WResult;
use crate::v5::write::WriteMqttPacket;
use crate::v5::MResult;

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901100")]
pub struct MPublish<'i> {
pub duplicate: bool,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/pubrec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ crate::v5::properties::define_properties![
}
];

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901131")]
pub struct MPubrec<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/pubrel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define_properties!(
}
);

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901141")]
pub struct MPubrel<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/suback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ crate::v5::properties::define_properties! {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901171")]
pub struct MSuback<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
12 changes: 9 additions & 3 deletions mqtt-format/src/v5/packets/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ define_properties! {
}
}

#[derive(Debug, num_enum::TryFromPrimitive, num_enum::IntoPrimitive, Clone, Copy)]
#[derive(Debug, num_enum::TryFromPrimitive, num_enum::IntoPrimitive, Clone, Copy, PartialEq)]
#[repr(u8)]
pub enum RetainHandling {
SendRetainedMessagesAlways = 0,
SendRetainedMessagesOnNewSubscribe = 1,
DoNotSendRetainedMessages = 2,
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct SubscriptionOptions {
pub quality_of_service: QualityOfService,
pub no_local: bool,
Expand Down Expand Up @@ -85,7 +85,7 @@ impl SubscriptionOptions {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901161")]
pub struct Subscription<'i> {
pub topic_filter: &'i str,
Expand Down Expand Up @@ -116,6 +116,12 @@ pub struct Subscriptions<'i> {
start: &'i [u8],
}

impl<'i> core::cmp::PartialEq for Subscriptions<'i> {
fn eq(&self, other: &Self) -> bool {
self.iter().eq(other.iter())
}
}

impl<'i> core::fmt::Debug for Subscriptions<'i> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Subscriptions").finish()
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/unsuback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ crate::v5::properties::define_properties! {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901187")]
pub struct MUnsuback<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
10 changes: 8 additions & 2 deletions mqtt-format/src/v5/packets/unsubscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct Unsubscriptions<'i> {
start: &'i [u8],
}

impl<'i> core::cmp::PartialEq for Unsubscriptions<'i> {
fn eq(&self, other: &Self) -> bool {
self.iter().eq(other.iter())
}
}

impl<'i> core::fmt::Debug for Unsubscriptions<'i> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Unsubscriptions").finish()
Expand Down Expand Up @@ -91,7 +97,7 @@ impl<'i> Iterator for UnsubscriptionsIter<'i> {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Unsubscription<'i> {
pub topic_filter: &'i str,
}
Expand All @@ -111,7 +117,7 @@ impl<'i> Unsubscription<'i> {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
#[doc = crate::v5::util::md_speclink!("_Toc3901179")]
pub struct MUnsubscribe<'i> {
pub packet_identifier: PacketIdentifier,
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ macro_rules! define_properties {
$(
#[doc = $crate::v5::util::md_speclink!($anker)]
)?
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct $name < $lt > {
$(
$(
Expand Down
4 changes: 2 additions & 2 deletions mqtt-format/src/v5/reason_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro_rules! make_combined_reason_code {
}) => {
#[derive(num_enum::TryFromPrimitive, num_enum::IntoPrimitive)]
#[repr(u8)]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum $name {
$( $reason_code_name = <$reason_code_type>::CODE ),*
}
Expand Down Expand Up @@ -42,7 +42,7 @@ pub(crate) use make_combined_reason_code;

macro_rules! define_reason_code {
($name:ident => $code:literal) => {
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct $name;
impl $name {
pub const CODE: u8 = $code;
Expand Down
12 changes: 9 additions & 3 deletions mqtt-format/src/v5/variable_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::write::WResult;
use super::write::WriteMqttPacket;
use super::MResult;

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PacketIdentifier(pub u16);

impl PacketIdentifier {
Expand Down Expand Up @@ -57,7 +57,7 @@ macro_rules! define_properties {
$(,)?
]) => {
$(
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct $name < $($tylt)? >(pub $(& $lt)? $kind);

impl<'lt $(, $tylt)?> MqttProperties<'lt> for $name < $($tylt)? >
Expand Down Expand Up @@ -99,7 +99,7 @@ macro_rules! define_properties {
}
)*

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum Property<'i> {
$(
$name ( $name $(< $tylt >)? ),
Expand Down Expand Up @@ -276,6 +276,12 @@ define_properties! {[

pub struct UserProperties<'i>(pub &'i [u8]);

impl<'i> core::cmp::PartialEq for UserProperties<'i> {
fn eq(&self, other: &Self) -> bool {
self.iter().eq(other.iter())
}
}

impl<'i> core::fmt::Debug for UserProperties<'i> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("UserProperties").finish()
Expand Down
Loading