Commit f8f81cc8 authored by Zeeshan Ali Khan's avatar Zeeshan Ali Khan
Browse files

zb,zv,zp,zm: Implement Eq for types implementing PartialEq

This fixes a clippy warning:

```
warning: you are deriving `PartialEq` and can implement `Eq`
   --> zbus/src/fdo.rs:452:57
    |
452 | #[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq)]
    |                                                         ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
```

For some of the types, we had to ignore the warning due to:

https://github.com/rust-lang/rust-clippy/issues/8970
parent b3625b71
......@@ -20,14 +20,14 @@ use uds_windows::UnixStream;
use std::ffi::OsString;
/// A `tcp:` address family.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum TcpAddressFamily {
Ipv4,
Ipv6,
}
/// A `tcp:` D-Bus address.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TcpAddress {
pub(crate) host: String,
pub(crate) bind: Option<String>,
......@@ -58,7 +58,7 @@ impl TcpAddress {
}
/// A bus address
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Address {
/// A path on the filesystem
......
......@@ -426,7 +426,7 @@ assert_impl_all!(StatsProxy<'_>: Send, Sync, Unpin);
/// [`request_name`]: struct.DBusProxy.html#method.request_name
#[bitflags]
#[repr(u32)]
#[derive(Type, Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
#[derive(Type, Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub enum RequestNameFlags {
/// If an application A specifies this flag and succeeds in becoming the owner of the name, and
/// another application B later calls [`request_name`] with the [`ReplaceExisting`] flag, then
......@@ -461,7 +461,7 @@ assert_impl_all!(RequestNameFlags: Send, Sync, Unpin);
///
/// [`request_name`]: struct.DBusProxy.html#method.request_name
#[repr(u32)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq, Eq)]
pub enum RequestNameReply {
/// The caller is now the primary owner of the name, replacing any previous owner. Either the
/// name had no owner before, or the caller specified [`ReplaceExisting`] and the current owner
......@@ -496,7 +496,7 @@ assert_impl_all!(RequestNameReply: Send, Sync, Unpin);
///
/// [`release_name`]: struct.DBusProxy.html#method.release_name
#[repr(u32)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq, Eq)]
pub enum ReleaseNameReply {
/// The caller has released their claim on the given name. Either the caller was the primary
/// owner of the name, and the name is now unused or taken by somebody waiting in the queue for
......@@ -521,7 +521,7 @@ assert_impl_all!(ReleaseNameReply: Send, Sync, Unpin);
///
/// **Note**: unknown keys, in particular those with "." that are not from the specification, will
/// be ignored. Use your own implementation or contribute your keys here, or in the specification.
#[derive(Debug, DeserializeDict, PartialEq, SerializeDict, Type)]
#[derive(Debug, DeserializeDict, PartialEq, Eq, SerializeDict, Type)]
#[zvariant(signature = "a{sv}")]
pub struct ConnectionCredentials {
/// The numeric Unix user ID, as defined by POSIX
......
......@@ -16,7 +16,7 @@ use static_assertions::assert_impl_all;
///
/// [UUIDs chapter]: https://dbus.freedesktop.org/doc/dbus-specification.html#uuids
/// [TryFrom]: #impl-TryFrom%3C%26%27_%20str%3E
#[derive(Clone, Debug, PartialEq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Guid(String);
assert_impl_all!(Guid: Send, Sync, Unpin);
......
......@@ -19,7 +19,7 @@ use crate::{
/// Authentication mechanisms
///
/// See <https://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms>
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AuthMechanism {
/// This is the recommended authentication mechanism on platforms where credentials can be
/// transferred out-of-band, in particular Unix platforms that can perform credentials-passing
......
......@@ -640,7 +640,7 @@ mod tests {
use zvariant::{OwnedValue, Type};
#[derive(
Debug, PartialEq, Clone, Type, OwnedValue, serde::Serialize, serde::Deserialize,
Debug, PartialEq, Eq, Clone, Type, OwnedValue, serde::Serialize, serde::Deserialize,
)]
pub struct DbusPath {
id: String,
......
......@@ -20,7 +20,7 @@ use zvariant::{ObjectPath, Signature, Type, Value};
/// [retrieve a specific field]: struct.MessageFields.html#method.get_field
/// [`MessageFields`]: struct.MessageFields.html
#[repr(u8)]
#[derive(Copy, Clone, Debug, Deserialize_repr, PartialEq, Serialize_repr, Type)]
#[derive(Copy, Clone, Debug, Deserialize_repr, PartialEq, Eq, Serialize_repr, Type)]
pub enum MessageFieldCode {
/// Code for [`MessageField::Invalid`](enum.MessageField.html#variant.Invalid)
Invalid = 0,
......@@ -92,7 +92,7 @@ impl<'f> MessageField<'f> {
/// [headers]: struct.MessageHeader.html
/// [are fixed]: struct.MessagePrimaryHeader.html
/// [Message Format]: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum MessageField<'f> {
/// Not a valid field.
Invalid,
......
......@@ -16,7 +16,7 @@ pub(crate) const MIN_MESSAGE_SIZE: usize = PRIMARY_HEADER_SIZE + 4;
/// D-Bus code for endianness.
#[repr(u8)]
#[derive(Debug, Copy, Clone, Deserialize_repr, PartialEq, Serialize_repr, Type)]
#[derive(Debug, Copy, Clone, Deserialize_repr, PartialEq, Eq, Serialize_repr, Type)]
pub enum EndianSig {
/// The D-Bus message is in big-endian (network) byte order.
Big = b'B',
......@@ -49,7 +49,7 @@ pub const NATIVE_ENDIAN_SIG: EndianSig = EndianSig::Little;
/// Message header representing the D-Bus type of the message.
#[repr(u8)]
#[derive(Debug, Copy, Clone, Deserialize_repr, PartialEq, Serialize_repr, Type)]
#[derive(Debug, Copy, Clone, Deserialize_repr, PartialEq, Eq, Serialize_repr, Type)]
pub enum MessageType {
/// Invalid message type. All unknown types on received messages are treated as invalid.
Invalid = 0,
......@@ -81,7 +81,7 @@ impl From<u8> for MessageType {
/// Pre-defined flags that can be passed in Message header.
#[bitflags]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Type)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type)]
pub enum MessageFlags {
/// This message does not expect method return replies or error replies, even if it is of a type
/// that can have a reply; the reply should be omitted.
......
......@@ -24,7 +24,7 @@ use futures_core::ready;
* Client-side handshake logic
*/
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[allow(clippy::upper_case_acronyms)]
enum ClientHandshakeStep {
Init,
......
......@@ -32,7 +32,7 @@ pub struct ArgStructTest {
// Mimic a NetworkManager interface property that's a dict. This tests ability to use a custom
// dict type using the `Type` And `*Dict` macros (issue #241).
#[derive(DeserializeDict, SerializeDict, Type, Debug, Value, OwnedValue, PartialEq)]
#[derive(DeserializeDict, SerializeDict, Type, Debug, Value, OwnedValue, PartialEq, Eq)]
#[zvariant(signature = "dict")]
pub struct IP4Adress {
prefix: u32,
......
......@@ -63,7 +63,7 @@ pub fn snake_case(s: &str) -> String {
snake
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum ItemAttribute {
Property(HashMap<String, String>),
Signal,
......
......@@ -12,7 +12,7 @@ use crate::Error;
/// Flags used in the CheckAuthorization() method.
#[bitflags]
#[repr(u32)]
#[derive(Type, Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
#[derive(Type, Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub enum CheckAuthorizationFlags {
/// If the Subject can obtain the authorization through authentication, and an authentication
/// agent is available, then attempt to do so. Note, this means that the CheckAuthorization()
......@@ -24,7 +24,7 @@ assert_impl_all!(CheckAuthorizationFlags: Send, Sync, Unpin);
/// An enumeration for granting implicit authorizations.
#[repr(u32)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq, Eq)]
pub enum ImplicitAuthorization {
/// The Subject is not authorized.
NotAuthorized = 0,
......@@ -45,7 +45,7 @@ assert_impl_all!(ImplicitAuthorization: Send, Sync, Unpin);
/// Flags describing features supported by the Authority implementation.
#[bitflags]
#[repr(u32)]
#[derive(Type, Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
#[derive(Type, Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub enum AuthorityFeatures {
/// The authority supports temporary authorizations that can be obtained through authentication.
TemporaryAuthorization = 0x01,
......
#![allow(unknown_lints)]
use serde::{
de::{DeserializeSeed, Deserializer, SeqAccess, Visitor},
ser::{Serialize, SerializeSeq, Serializer},
......@@ -16,6 +17,8 @@ use crate::{
/// [`Value`]: enum.Value.html#variant.Array
/// [`Vec`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
#[derive(Debug, Clone, PartialEq)]
// FIXME: Workaround for https://github.com/rust-lang/rust-clippy/issues/8970
#[allow(clippy::derive_partial_eq_without_eq)]
pub struct Array<'a> {
element_signature: Signature<'a>,
elements: Vec<Value<'a>>,
......@@ -259,6 +262,8 @@ impl<'de> DeserializeSeed<'de> for ArraySeed<'de> {
}
#[derive(Debug, Clone, PartialEq)]
// FIXME: Workaround for https://github.com/rust-lang/rust-clippy/issues/8970
#[allow(clippy::derive_partial_eq_without_eq)]
struct ArrayVisitor<'a> {
signature: Signature<'a>,
}
......
......@@ -4,7 +4,7 @@ use static_assertions::assert_impl_all;
/// The encoding format.
///
#[derive(Debug, PartialEq, Copy, Clone)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum EncodingFormat {
/// [D-Bus](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling)
/// format.
......@@ -61,7 +61,7 @@ impl std::fmt::Display for EncodingFormat {
/// [serialization and deserialization]: index.html#functions
/// [ByteOrder]: https://docs.rs/byteorder/1.3.4/byteorder/trait.ByteOrder.html
/// [specify]: #method.new
#[derive(Debug, PartialEq, Copy, Clone)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct EncodingContext<B> {
format: EncodingFormat,
position: usize,
......
......@@ -6,7 +6,7 @@ use byteorder::{ByteOrder, WriteBytesExt, LE};
// GVariant containers keeps framing offsets at the end and size of these offsets is dependent on
// the size of the container (which includes offsets themselves.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(usize)]
pub(crate) enum FramingOffsetSize {
U8 = 1,
......
......@@ -452,7 +452,7 @@ fn ensure_correct_signature_str(signature: &[u8]) -> Result<()> {
}
/// Owned [`Signature`](struct.Signature.html)
#[derive(Debug, Clone, PartialEq, serde::Serialize, Type)]
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, Type)]
pub struct OwnedSignature(Signature<'static>);
assert_impl_all!(OwnedSignature: Send, Sync, Unpin);
......
#![allow(unknown_lints)]
use serde::{
de::{DeserializeSeed, Deserializer, SeqAccess, Visitor},
ser::{Serialize, SerializeTupleStruct, Serializer},
......@@ -14,6 +15,8 @@ use crate::{
///
/// [`Structure`]: struct.Structure.html
#[derive(Debug, Default, Clone, PartialEq)]
// FIXME: Workaround for https://github.com/rust-lang/rust-clippy/issues/8970
#[allow(clippy::derive_partial_eq_without_eq)]
pub struct StructureBuilder<'a>(Vec<Value<'a>>);
assert_impl_all!(StructureBuilder<'_>: Send, Sync, Unpin);
......@@ -90,6 +93,8 @@ impl<'a> StructureBuilder<'a> {
///
/// [`Structure`]: struct.Structure.html
#[derive(Debug, Clone, PartialEq)]
// FIXME: Workaround for https://github.com/rust-lang/rust-clippy/issues/8970
#[allow(clippy::derive_partial_eq_without_eq)]
pub struct StructureSeed<'a>(Signature<'a>);
assert_impl_all!(StructureSeed<'_>: Send, Sync, Unpin);
......@@ -127,6 +132,8 @@ impl<'de> DeserializeSeed<'de> for StructureSeed<'de> {
}
#[derive(Debug, Clone, PartialEq)]
// FIXME: Workaround for https://github.com/rust-lang/rust-clippy/issues/8970
#[allow(clippy::derive_partial_eq_without_eq)]
struct StructureVisitor<'a> {
signature: Signature<'a>,
}
......@@ -155,6 +162,8 @@ impl<'de> Visitor<'de> for StructureVisitor<'de> {
///
/// [`Value`]: enum.Value.html
#[derive(Debug, Clone, PartialEq)]
// FIXME: Workaround for https://github.com/rust-lang/rust-clippy/issues/8970
#[allow(clippy::derive_partial_eq_without_eq)]
pub struct Structure<'a> {
fields: Vec<Value<'a>>,
signature: Signature<'a>,
......
......@@ -51,7 +51,7 @@ fn parse_attribute(meta: &NestedMeta) -> (String, String) {
(ident.to_string(), value)
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum ItemAttribute {
Rename(String),
Signature(String),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment