diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-10-31 22:54:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-10-31 22:54:00 +0900 |
| commit | 151461d55c16a96a305a67d0923acdd574687056 (patch) | |
| tree | 7464865fe584f9ee8b563083cf52a8d4c40a5e92 /plugins/tokenize-ja/src/lib.rs | |
| parent | 8c9dfe3472933cf466bf62c83a8303fa35c28409 (diff) | |
| download | phpstudy-N-slides-template-151461d55c16a96a305a67d0923acdd574687056.tar.gz phpstudy-N-slides-template-151461d55c16a96a305a67d0923acdd574687056.tar.zst phpstudy-N-slides-template-151461d55c16a96a305a67d0923acdd574687056.zip | |
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) +} |
