DOC-301 实现 Rust 侧阅读事件缓冲区 #27
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
docs/app-rust-bridge.md定义了以下两个 Rust 函数,但代码中未实现:现状
ReadingEvent类型已定义(events.rs),54 个单元测试全过ReadingPosition类型已定义并已通过 UDL 暴露到 iOSupdate_reading_position()也未实现需要实现
update_reading_position(material_id, position)— 记录位置变更export_pending_events()— 返回所有未导出事件clear_exported_events(count)— 确认前 count 条已上传验收标准
实现完成 (2026-06-02)
Rust Core (
events.rs)添加全局事件缓冲区:
新增 4 个函数:
push_reading_event(event)update_reading_position(material_id, position)export_pending_events() → Vec<ReadingEvent>clear_exported_events(count)辅助函数:
now_ms()— UNIX 毫秒时间戳FFI / UDL 暴露
UDL 新增 4 个 namespace 函数:
void push_reading_event(ReadingEvent event)void update_reading_position(string material_id, ReadingPosition position)sequence<ReadingEvent> export_pending_events()void clear_exported_events(u32 count)测试
新增 4 个单元测试:
test_push_and_export— 推入 → 导出数量正确test_clear_exported— 部分清除后缓冲区剩余正确test_update_reading_position— 位置变更自动生成 PositionChanged 事件test_empty_export— 空缓冲区导出为空全部 58 测试通过,零警告。
产物
pushReadingEvent(event:)/exportPendingEvents()/clearExportedEvents(count:)/updateReadingPosition(materialId:position:)关闭
DOC-301 被 V2 替代 — events_v2.rs (DOC-FULL-003+006) 已实现完整 buffer + ack