DOC-302a zx_document_core 类型迁移到 proc-macro #30
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?
目标
给 zx_document_core 的所有导出类型加 UniFFI proc-macro derive。
FFI DTO 边界规则(重要)
优先只给 FFI 边界类型添加 UniFFI derive。
需要标注的类型
Enum(
#[derive(uniffi::Enum)])MaterialType(material_type.rs)PreviewMode(material_type.rs)DocumentBlock(blocks.rs)ReadingPosition(progress.rs)ReadingEvent(events.rs)NoteAnchor(anchors.rs)Record(
#[derive(uniffi::Record)])DocumentInfo(document.rs)ImageMeta(image_meta.rs)TextStats(text.rs)SearchResult(search.rs)Error(
#[derive(uniffi::Error)])DocumentError(error.rs)改动
uniffi = "0.28"依赖#[derive(uniffi::*)]#[derive(serde::*)]等 derive依赖
验收
cargo build -p zx_document_core通过cargo test58 测试全过完成 (2026-06-03)
改动
zx_document_core/Cargo.toml添加uniffi = "0.28"依赖 +build-dependenciescrates/zx_document_core/build.rs— 最小 scaffolding 生成lib.rs添加uniffi::setup_scaffolding!()#[derive(uniffi::Enum)]→ MaterialType, PreviewMode, ReadingPosition, ReadingEvent, NoteAnchor#[derive(uniffi::Record)]→ DocumentInfo, ImageMeta, TextStats, SearchResult#[derive(uniffi::Enum)]仅 FFI crate → DocumentBlock (core 版本跳过,FFI wrapper 替代)IoError(std::io::Error)不兼容 UniFFI)遵守 FFI DTO 边界规则
验证
cargo build通过,零警告cargo test58 测试全过关闭
DOC-302a 已完成 — 类型已迁移到 proc-macro