2024-06-22 21:14:05 -04:00
|
|
|
use crate::guac;
|
2024-06-19 01:36:07 -04:00
|
|
|
|
2024-08-20 06:14:08 -04:00
|
|
|
use napi_derive::napi;
|
2024-06-19 01:36:07 -04:00
|
|
|
|
2024-08-20 06:14:08 -04:00
|
|
|
#[napi(js_name = "guacDecode")]
|
|
|
|
|
#[allow(unused)]
|
|
|
|
|
pub fn guac_decode(input: String) -> napi::anyhow::Result<Vec<String>> {
|
2024-08-04 15:59:39 -04:00
|
|
|
match guac::decode_instruction(&input) {
|
2024-08-20 06:14:08 -04:00
|
|
|
Ok(elements) => Ok(elements),
|
2024-06-19 01:36:07 -04:00
|
|
|
|
2024-08-20 06:14:08 -04:00
|
|
|
Err(err) => Err(anyhow::anyhow!("Error decoding Guacamole frame: {}", err)),
|
2024-08-04 15:59:39 -04:00
|
|
|
}
|
2024-06-19 01:36:07 -04:00
|
|
|
}
|
|
|
|
|
|
2024-08-20 06:14:08 -04:00
|
|
|
// ... 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))
|
2024-06-19 01:36:07 -04:00
|
|
|
}
|