feat: UniFFI setup - UDL interface, build.rs scaffolding, cargo check passes
This commit is contained in:
parent
65bc52bfd7
commit
9481cc20e9
@ -3,4 +3,12 @@ name = "zx_document_ffi"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["lib", "staticlib", "cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
zx_document_core = { path = "../zx_document_core" }
|
||||||
|
uniffi = "0.28"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
uniffi = { version = "0.28", features = ["build"] }
|
||||||
|
|||||||
3
crates/zx_document_ffi/build.rs
Normal file
3
crates/zx_document_ffi/build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
uniffi::generate_scaffolding("src/zx_document.udl").unwrap();
|
||||||
|
}
|
||||||
@ -1,2 +1 @@
|
|||||||
// FFI bindings — generated by UniFFI
|
uniffi::setup_scaffolding!();
|
||||||
// See zx_document.udl for interface definitions
|
|
||||||
|
|||||||
@ -0,0 +1,92 @@
|
|||||||
|
namespace zx_document {};
|
||||||
|
|
||||||
|
[Enum]
|
||||||
|
interface MaterialType {
|
||||||
|
Markdown();
|
||||||
|
Text();
|
||||||
|
Pdf();
|
||||||
|
Image();
|
||||||
|
Epub();
|
||||||
|
Word();
|
||||||
|
Excel();
|
||||||
|
PowerPoint();
|
||||||
|
Unknown();
|
||||||
|
};
|
||||||
|
|
||||||
|
[Enum]
|
||||||
|
interface PreviewMode {
|
||||||
|
NativeReader();
|
||||||
|
PlatformPreview();
|
||||||
|
ExternalOpen();
|
||||||
|
Unsupported();
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary DocumentInfo {
|
||||||
|
string material_id;
|
||||||
|
string title;
|
||||||
|
MaterialType material_type;
|
||||||
|
PreviewMode preview_mode;
|
||||||
|
u64 file_size;
|
||||||
|
u32? page_count;
|
||||||
|
u32? word_count;
|
||||||
|
string? created_at;
|
||||||
|
};
|
||||||
|
|
||||||
|
[Enum]
|
||||||
|
interface ReadingPosition {
|
||||||
|
Markdown(string block_id, f32 scroll_progress);
|
||||||
|
Text(u32 line_number, f32 scroll_progress);
|
||||||
|
Pdf(u32 page_number, f32 page_progress, f32 overall_progress);
|
||||||
|
Image(f32 zoom_scale, f32 offset_x, f32 offset_y);
|
||||||
|
Epub(string chapter_id, f32 chapter_progress, f32 overall_progress);
|
||||||
|
Unknown();
|
||||||
|
};
|
||||||
|
|
||||||
|
[Enum]
|
||||||
|
interface ReadingEvent {
|
||||||
|
MaterialOpened(string material_id, i64 timestamp_ms);
|
||||||
|
MaterialClosed(string material_id, i64 timestamp_ms, u32 active_seconds);
|
||||||
|
PositionChanged(string material_id, ReadingPosition position, i64 timestamp_ms);
|
||||||
|
Heartbeat(string material_id, u32 active_seconds, ReadingPosition? position, i64 timestamp_ms);
|
||||||
|
MarkedAsRead(string material_id, i64 timestamp_ms);
|
||||||
|
};
|
||||||
|
|
||||||
|
[Enum]
|
||||||
|
interface NoteAnchor {
|
||||||
|
Material(string material_id);
|
||||||
|
MarkdownBlock(string material_id, string block_id);
|
||||||
|
TextLine(string material_id, u32 line_number);
|
||||||
|
PdfPage(string material_id, u32 page_number);
|
||||||
|
Image(string material_id);
|
||||||
|
EpubChapter(string material_id, string chapter_id);
|
||||||
|
KnowledgeItem(string knowledge_item_id);
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary ImageMeta {
|
||||||
|
u32 width;
|
||||||
|
u32 height;
|
||||||
|
string format;
|
||||||
|
u64 file_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary SearchResult {
|
||||||
|
string block_id;
|
||||||
|
u32? line_number;
|
||||||
|
string snippet;
|
||||||
|
u64 match_start;
|
||||||
|
u64 match_end;
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary TextStats {
|
||||||
|
u32 line_count;
|
||||||
|
u32 word_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
[Error]
|
||||||
|
enum DocumentError {
|
||||||
|
"FileNotFound",
|
||||||
|
"UnsupportedFormat",
|
||||||
|
"ParseError",
|
||||||
|
"InvalidEncoding",
|
||||||
|
"IoError",
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user