From eeaa091024bcd94421882077d88bd1b65fdeecfa Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 16 May 2025 13:57:25 +0200 Subject: [PATCH] chore(ffi): Justify the `allow(clippy::large_enum_variant)`. --- bindings/matrix-sdk-ffi/src/event.rs | 16 ++++++++++++++++ bindings/matrix-sdk-ffi/src/timeline/content.rs | 8 ++++++++ bindings/matrix-sdk-ffi/src/timeline/msg_like.rs | 1 + bindings/matrix-sdk-ffi/src/timeline/reply.rs | 1 + 4 files changed, 26 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/event.rs b/bindings/matrix-sdk-ffi/src/event.rs index 9209d0e9b..4e0977dd6 100644 --- a/bindings/matrix-sdk-ffi/src/event.rs +++ b/bindings/matrix-sdk-ffi/src/event.rs @@ -60,6 +60,14 @@ impl From for TimelineEvent { } #[derive(uniffi::Enum)] +// A note about this `allow(clippy::large_enum_variant)`. +// In order to reduce the size of `TimelineEventType`, we would need to +// put some parts in a `Box`, or an `Arc`. Sadly, it doesn't play well with +// UniFFI. We would need to change the `uniffi::Record` of the subtypes into +// `uniffi::Object`, which is a radical change. It would simplify the memory +// usage, but it would slow down the performance around the FFI border. Thus, +// let's consider this is a false-positive lint in this particular case. +#[allow(clippy::large_enum_variant)] pub enum TimelineEventType { MessageLike { content: MessageLikeEventContent }, State { content: StateEventContent }, @@ -134,6 +142,14 @@ impl TryFrom for StateEventContent { } #[derive(uniffi::Enum)] +// A note about this `allow(clippy::large_enum_variant)`. +// In order to reduce the size of `MessageLineEventContent`, we would need to +// put some parts in a `Box`, or an `Arc`. Sadly, it doesn't play well with +// UniFFI. We would need to change the `uniffi::Record` of the subtypes into +// `uniffi::Object`, which is a radical change. It would simplify the memory +// usage, but it would slow down the performance around the FFI border. Thus, +// let's consider this is a false-positive lint in this particular case. +#[allow(clippy::large_enum_variant)] pub enum MessageLikeEventContent { CallAnswer, CallInvite, diff --git a/bindings/matrix-sdk-ffi/src/timeline/content.rs b/bindings/matrix-sdk-ffi/src/timeline/content.rs index 30fbf4560..f0320d946 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/content.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/content.rs @@ -96,6 +96,14 @@ impl From for TimelineItemContent } #[derive(Clone, uniffi::Enum)] +// A note about this `allow(clippy::large_enum_variant)`. +// In order to reduce the size of `TimelineItemContent`, we would need to +// put some parts in a `Box`, or an `Arc`. Sadly, it doesn't play well with +// UniFFI. We would need to change the `uniffi::Record` of the subtypes into +// `uniffi::Object`, which is a radical change. It would simplify the memory +// usage, but it would slow down the performance around the FFI border. Thus, +// let's consider this is a false-positive lint in this particular case. +#[allow(clippy::large_enum_variant)] pub enum TimelineItemContent { MsgLike { content: MsgLikeContent, diff --git a/bindings/matrix-sdk-ffi/src/timeline/msg_like.rs b/bindings/matrix-sdk-ffi/src/timeline/msg_like.rs index 18ad4a6d0..87131d715 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/msg_like.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/msg_like.rs @@ -252,6 +252,7 @@ impl ThreadSummary { } #[derive(Clone, uniffi::Enum)] +#[allow(clippy::large_enum_variant)] pub enum ThreadSummaryLatestEventDetails { Unavailable, Pending, diff --git a/bindings/matrix-sdk-ffi/src/timeline/reply.rs b/bindings/matrix-sdk-ffi/src/timeline/reply.rs index 0b1d5d388..6c5a964fc 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/reply.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/reply.rs @@ -60,6 +60,7 @@ impl From for InReplyToDetails { } #[derive(Clone, uniffi::Enum)] +#[allow(clippy::large_enum_variant)] pub enum RepliedToEventDetails { Unavailable, Pending,