pub struct NotificationMessage {
pub notification_id: Option<u64>,
pub notification_type: NotificationType,
pub display_text: String,
pub timestamp: i64,
pub channel_id: u64,
pub channel_type: u8,
pub should_persist: bool,
pub metadata: Option<Value>,
}Expand description
通知消息结构
封装通知类型和相关元数据,用于在会话中显示系统通知
Fields§
§notification_id: Option<u64>通知ID(可选,用于去重)
notification_type: NotificationType通知类型
display_text: String显示文本(用于UI展示,可以根据语言本地化)
timestamp: i64时间戳
channel_id: u64所属会话ID
channel_type: u8会话类型(1=私聊, 2=群聊)
should_persist: bool是否需要持久化存储
metadata: Option<Value>额外元数据(可选)
Implementations§
Source§impl NotificationMessage
impl NotificationMessage
Sourcepub fn new(
notification_type: NotificationType,
display_text: String,
channel_id: u64,
channel_type: u8,
) -> Self
pub fn new( notification_type: NotificationType, display_text: String, channel_id: u64, channel_type: u8, ) -> Self
创建新的通知消息
Sourcepub fn with_notification_id(self, id: u64) -> Self
pub fn with_notification_id(self, id: u64) -> Self
设置通知ID
Sourcepub fn with_persist(self, persist: bool) -> Self
pub fn with_persist(self, persist: bool) -> Self
设置是否持久化
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
设置额外元数据
Source§impl NotificationMessage
辅助函数:生成显示文本
impl NotificationMessage
辅助函数:生成显示文本
Sourcepub fn generate_display_text_cn(notification_type: &NotificationType) -> String
pub fn generate_display_text_cn(notification_type: &NotificationType) -> String
根据通知类型生成默认的显示文本(中文)
Trait Implementations§
Source§impl Clone for NotificationMessage
impl Clone for NotificationMessage
Source§fn clone(&self) -> NotificationMessage
fn clone(&self) -> NotificationMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NotificationMessage
impl Debug for NotificationMessage
Source§impl<'de> Deserialize<'de> for NotificationMessage
impl<'de> Deserialize<'de> for NotificationMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for NotificationMessage
impl RefUnwindSafe for NotificationMessage
impl Send for NotificationMessage
impl Sync for NotificationMessage
impl Unpin for NotificationMessage
impl UnsafeUnpin for NotificationMessage
impl UnwindSafe for NotificationMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more