Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,8 @@ pub use self::metrics::{ConsumerStatus, ParserStatus, ReportedError};
pub mod value_access;
pub use self::value_access::{JsonDecode, ValueAccess};

pub mod support;
pub use self::support::{SupportAgent, SupportConversation, SupportConversationStatus, SupportMessage, SupportMessageDeliveryStatus, SupportMessageDirection};

#[cfg(any(test, feature = "testkit"))]
pub mod testkit;
65 changes: 65 additions & 0 deletions crates/primitives/src/support.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use typeshare::typeshare;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[typeshare(swift = "Equatable, CaseIterable, Sendable")]
#[serde(rename_all = "lowercase")]
pub enum SupportConversationStatus {
Open,
Resolved,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[typeshare(swift = "Equatable, CaseIterable, Sendable")]
#[serde(rename_all = "lowercase")]
pub enum SupportMessageDirection {
Incoming,
Outgoing,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[typeshare(swift = "Equatable, CaseIterable, Sendable")]
#[serde(rename_all = "lowercase")]
pub enum SupportMessageDeliveryStatus {
Sending,
Sent,
Failed,
}

#[derive(Debug, Clone, Serialize, Deserialize)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The SupportAgent struct is marked with #[typeshare(swift = "Sendable, Equatable")], indicating it should be equatable. However, the Rust struct does not derive PartialEq or Eq. To ensure consistency between the Rust models and the generated Swift models, and to allow equality comparisons in Rust (especially useful for testing), please derive PartialEq and Eq.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

#[typeshare(swift = "Sendable, Equatable")]
#[serde(rename_all = "camelCase")]
pub struct SupportAgent {
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The SupportConversation struct is marked with #[typeshare(swift = "Sendable, Equatable, Hashable, Identifiable")], but it does not derive PartialEq or Eq in Rust. To align with the Swift typeshare attributes and enable equality comparisons in Rust, please derive PartialEq and Eq.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

#[typeshare(swift = "Sendable, Equatable, Hashable, Identifiable")]
#[serde(rename_all = "camelCase")]
pub struct SupportConversation {
pub id: String,
pub status: SupportConversationStatus,
#[serde(skip_serializing_if = "Option::is_none")]
pub first_message: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_message: Option<String>,
pub last_activity_at: DateTime<Utc>,
pub unread_count: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The SupportMessage struct is marked with #[typeshare(swift = "Sendable, Equatable")], but it does not derive PartialEq or Eq in Rust. Please derive PartialEq and Eq to ensure consistency with the Swift typeshare definitions and to support equality assertions in Rust tests.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

#[typeshare(swift = "Sendable, Equatable")]
#[serde(rename_all = "camelCase")]
pub struct SupportMessage {
pub id: String,
pub conversation_id: String,
pub content: String,
pub direction: SupportMessageDirection,
pub delivery_status: SupportMessageDeliveryStatus,
#[serde(skip_serializing_if = "Option::is_none")]
pub agent: Option<SupportAgent>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do non optional

pub created_at: DateTime<Utc>,
}
Loading