- switch to napi-rs. this mostly affects only the backend side of things, but IMO napi-rs is better (also, way less boilerplate is needed compared to neon). - jpeg encoding no longer clones the input buffer internally (or wraps it in a Mutex as well), thanks to napi-rs not sucking in this regard. this is *probably* a micro-optimization, but will make it easier to later on do parallel encoding of all rectangles - guac encoding is weird. This is kind of a painpoint of napi-rs but it's bearable
21 lines
521 B
Rust
21 lines
521 B
Rust
use crate::guac;
|
|
|
|
use napi_derive::napi;
|
|
|
|
#[napi(js_name = "guacDecode")]
|
|
#[allow(unused)]
|
|
pub fn guac_decode(input: String) -> napi::anyhow::Result<Vec<String>> {
|
|
match guac::decode_instruction(&input) {
|
|
Ok(elements) => Ok(elements),
|
|
|
|
Err(err) => Err(anyhow::anyhow!("Error decoding Guacamole frame: {}", err)),
|
|
}
|
|
}
|
|
|
|
// ... this is ugly, but works
|
|
#[napi(js_name = "guacEncodeImpl")]
|
|
#[allow(unused)]
|
|
pub fn guac_encode(items: Vec<String>) -> napi::anyhow::Result<String> {
|
|
Ok(guac::encode_instruction(&items))
|
|
}
|