agent-context 0.1.3

Multi-backend agent context manager with three-zone memory model
Documentation
//! 订阅管理请求消息。
//!
//! 动态管理 [`AgentContext`](crate::AgentContext) 的订阅者,支持 spawn 后随时订阅/退订。

use kameo::actor::{Recipient, ReplyRecipient};

use super::outbound::{NotifyChange, NotifyCompressedForReply};

/// 添加变更通知订阅者。Reply = `()`。
///
/// 订阅后,每次对 incremental 区的写操作都会通过 [`NotifyChange`] 通知该订阅者。
/// 可重复调用注册多个订阅者。若该订阅者已存在则无操作。
pub struct RequestSubscribeChange<M: Send + 'static> {
    /// 要添加的订阅者引用
    pub recipient: Recipient<NotifyChange<M>>,
}

/// 移除变更通知订阅者。Reply = `bool`。
///
/// 返回 `true` 表示该订阅者存在并被移除,`false` 表示未找到。
pub struct RequestUnsubscribeChange<M: Send + 'static> {
    /// 要移除的订阅者引用
    pub recipient: Recipient<NotifyChange<M>>,
}

/// 设置压缩结果订阅者。Reply = `()`。
///
/// 在 [`RequestCompress`](super::inbound::RequestCompress) 生成摘要后、写入 compressed 区之前,
/// 将 [`NotifyCompressedForReply`] 发送给订阅者,订阅者返回修改后的 `(摘要, 保留)` 对。
/// 后设覆盖前设(单例语义)。
pub struct RequestSubscribeCompressed<M: Send + 'static> {
    /// 压缩结果订阅者引用
    pub recipient: ReplyRecipient<NotifyCompressedForReply<M>, (Vec<M>, Vec<M>)>,
}

/// 清除压缩结果订阅者。Reply = `()`。
///
/// 清除后 [`RequestCompress`](super::inbound::RequestCompress) 将跳过订阅者处理,直接使用原始摘要。
pub struct RequestUnsubscribeCompressed;