IOS-INFO-003:定义 ReadingRuntimeAdapter 协议 #111

Open
opened 2026-06-10 21:28:08 +08:00 by wangdl · 0 comments
Owner

目标

定义 iOS 侧 Runtime 抽象协议,屏蔽 V1 / V2 Rust document runtime 差异,避免页面直接依赖 UniFFI 具体实现。

协议方法建议

protocol ReadingRuntimeAdapter {
    func openSession(context: ReadingMaterialContext, timestamp: Date) async throws -> ReadingRuntimeSession
    func closeSession(sessionId: String, position: ReadingPositionDTO?, timestamp: Date) async throws
    func heartbeat(sessionId: String, timestamp: Date) async throws
    func recordPositionChanged(sessionId: String, position: ReadingPositionDTO, timestamp: Date) async throws
    func recordMarkedAsRead(sessionId: String, position: ReadingPositionDTO?, timestamp: Date) async throws
    func exportPendingEvents(limit: Int?) async throws -> [RuntimeReadingEventDTO]
    func ackEvents(eventIds: [String]) async throws
    func markEventsFailed(eventIds: [String], reason: String?) async throws
    func getBufferState() async throws -> RuntimeEventBufferState
}

需要实现

  • V1ReadingRuntimeAdapter
  • V2ReadingRuntimeAdapter
  • NoopReadingRuntimeAdapter

验收标准

  1. 新增 ReadingRuntimeAdapter 协议。
  2. 页面层不直接调用 UniFFI。
  3. V1 adapter 可兼容旧逻辑。
  4. V2 adapter 对接 Rust V2 FFI。
  5. Noop adapter 可用于测试 / fallback。
  6. 有 mock adapter 测试。
## 目标 定义 iOS 侧 Runtime 抽象协议,屏蔽 V1 / V2 Rust document runtime 差异,避免页面直接依赖 UniFFI 具体实现。 ## 协议方法建议 ```swift protocol ReadingRuntimeAdapter { func openSession(context: ReadingMaterialContext, timestamp: Date) async throws -> ReadingRuntimeSession func closeSession(sessionId: String, position: ReadingPositionDTO?, timestamp: Date) async throws func heartbeat(sessionId: String, timestamp: Date) async throws func recordPositionChanged(sessionId: String, position: ReadingPositionDTO, timestamp: Date) async throws func recordMarkedAsRead(sessionId: String, position: ReadingPositionDTO?, timestamp: Date) async throws func exportPendingEvents(limit: Int?) async throws -> [RuntimeReadingEventDTO] func ackEvents(eventIds: [String]) async throws func markEventsFailed(eventIds: [String], reason: String?) async throws func getBufferState() async throws -> RuntimeEventBufferState } ``` ## 需要实现 - V1ReadingRuntimeAdapter - V2ReadingRuntimeAdapter - NoopReadingRuntimeAdapter ## 验收标准 1. 新增 ReadingRuntimeAdapter 协议。 2. 页面层不直接调用 UniFFI。 3. V1 adapter 可兼容旧逻辑。 4. V2 adapter 对接 Rust V2 FFI。 5. Noop adapter 可用于测试 / fallback。 6. 有 mock adapter 测试。
wangdl added this to the M-IOS-INFO:学习信息采集、上传、继续学习与基础分析闭环 milestone 2026-06-10 21:28:08 +08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/ios-projects#111
No description provided.