diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-03-21 15:16:17 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-03-21 15:16:17 +0900 |
| commit | 56547d348ccaca4369560a5fe69aba44c2521ebd (patch) | |
| tree | d4c977985900ee1ee87ced1e43986653932c791d /plugins/tokenize-ja/src/lib.rs | |
| parent | b00d51802e6a5bd5dc46d9ab64ce6376d7f0121b (diff) | |
| download | phperkaigi-2026-php-modification-slides-56547d348ccaca4369560a5fe69aba44c2521ebd.tar.gz phperkaigi-2026-php-modification-slides-56547d348ccaca4369560a5fe69aba44c2521ebd.tar.zst phperkaigi-2026-php-modification-slides-56547d348ccaca4369560a5fe69aba44c2521ebd.zip | |
wip
Diffstat (limited to 'plugins/tokenize-ja/src/lib.rs')
| -rw-r--r-- | plugins/tokenize-ja/src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/tokenize-ja/src/lib.rs b/plugins/tokenize-ja/src/lib.rs new file mode 100644 index 0000000..fb58250 --- /dev/null +++ b/plugins/tokenize-ja/src/lib.rs @@ -0,0 +1,20 @@ +use ciborium::ser::into_writer; +use wasm_minimal_protocol::*; + +initiate_protocol!(); + +mod tokenize; + +#[wasm_func] +pub fn init() -> Result<Vec<u8>, anyhow::Error> { + tokenize::init()?; + Ok(Vec::new()) +} + +#[wasm_func] +pub fn tokenize(text: &[u8]) -> Result<Vec<u8>, anyhow::Error> { + let result = tokenize::tokenize(str::from_utf8(text)?)?; + let mut out = Vec::new(); + into_writer(&result, &mut out)?; + Ok(out) +} |
