diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7530c05..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rust-analyzer.server.extraEnv": { "CARGO": "cargo-component" } -} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 6370699..b44ac7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -40,18 +40,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.61" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -97,9 +97,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "wit-bindgen" -version = "0.17.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "a84376ff4f74ed07674a1157c0bd19e6627ab01fc90952a27ccefb52a24530f0" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/Cargo.toml b/Cargo.toml index 843c2f9..5c1277e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,11 +12,10 @@ lto = true opt-level = 's' [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen = { version = "0.26.0", default-features = false, features = ["realloc"] } serde = "*" serde_json = "*" [package.metadata.component.target] path = "wit" -[package.metadata.component.target.dependencies] diff --git a/src/bindings.rs b/src/bindings.rs deleted file mode 100644 index e9b2401..0000000 --- a/src/bindings.rs +++ /dev/null @@ -1,391 +0,0 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -pub mod exports { - pub mod golem { - pub mod component { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#add"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_add(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - <_GuestImpl as Guest>::add(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::get(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Some(e) => { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } - }, - };ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:component/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#listpaths"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_listpaths() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::listpaths(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec3 = result0; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); - let result3 = if layout3.size() != 0 - { - let ptr = alloc::alloc(layout3); - if ptr.is_null() - { - alloc::handle_alloc_error(layout3); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec3.into_iter().enumerate() { - let base = result3 as i32 + (i as i32) * 8; - { - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((base + 4) as *mut i32) = len2; - *((base + 0) as *mut i32) = ptr2; - } - } - *((ptr1 + 4) as *mut i32) = len3; - *((ptr1 + 0) as *mut i32) = result3 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:component/api#listpaths"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_listpaths(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *8; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#addtree"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_addtree(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::addtree(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Ok(_) => { { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - } }, - };ptr3 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:component/api#addtree"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_addtree(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#gettree"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_gettree(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::gettree(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Some(e) => { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } - }, - };ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:component/api#gettree"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_gettree(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#delete"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_delete(arg0: i32,arg1: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::delete(wit_bindgen::rt::string_lift(bytes0)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#drop"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_drop() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::drop(); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn add(path: wit_bindgen::rt::string::String,value: wit_bindgen::rt::string::String,); - fn get(path: wit_bindgen::rt::string::String,) -> Option; - fn listpaths() -> wit_bindgen::rt::vec::Vec::; - fn addtree(path: wit_bindgen::rt::string::String,json: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - /// fetch an entire subtree rooted at path - fn gettree(path: wit_bindgen::rt::string::String,) -> Option; - fn delete(path: wit_bindgen::rt::string::String,); - fn drop(); - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - - } - } -} - -#[cfg(target_arch = "wasm32")] -#[link_section = "component-type:slkvs"] -#[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 741] = [3, 0, 5, 115, 108, 107, 118, 115, 0, 97, 115, 109, 13, 0, 1, 0, 7, 182, 1, 1, 65, 2, 1, 66, 16, 1, 64, 2, 4, 112, 97, 116, 104, 115, 5, 118, 97, 108, 117, 101, 115, 1, 0, 4, 0, 3, 97, 100, 100, 1, 0, 1, 107, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 1, 4, 0, 3, 103, 101, 116, 1, 2, 1, 112, 115, 1, 64, 0, 0, 3, 4, 0, 9, 108, 105, 115, 116, 112, 97, 116, 104, 115, 1, 4, 1, 106, 0, 1, 115, 1, 64, 2, 4, 112, 97, 116, 104, 115, 4, 106, 115, 111, 110, 115, 0, 5, 4, 0, 7, 97, 100, 100, 116, 114, 101, 101, 1, 6, 4, 0, 7, 103, 101, 116, 116, 114, 101, 101, 1, 2, 1, 64, 1, 4, 112, 97, 116, 104, 115, 1, 0, 4, 0, 6, 100, 101, 108, 101, 116, 101, 1, 7, 1, 64, 0, 1, 0, 4, 0, 4, 100, 114, 111, 112, 1, 8, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 211, 1, 1, 65, 2, 1, 65, 2, 1, 66, 16, 1, 64, 2, 4, 112, 97, 116, 104, 115, 5, 118, 97, 108, 117, 101, 115, 1, 0, 4, 0, 3, 97, 100, 100, 1, 0, 1, 107, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 1, 4, 0, 3, 103, 101, 116, 1, 2, 1, 112, 115, 1, 64, 0, 0, 3, 4, 0, 9, 108, 105, 115, 116, 112, 97, 116, 104, 115, 1, 4, 1, 106, 0, 1, 115, 1, 64, 2, 4, 112, 97, 116, 104, 115, 4, 106, 115, 111, 110, 115, 0, 5, 4, 0, 7, 97, 100, 100, 116, 114, 101, 101, 1, 6, 4, 0, 7, 103, 101, 116, 116, 114, 101, 101, 1, 2, 1, 64, 1, 4, 112, 97, 116, 104, 115, 1, 0, 4, 0, 6, 100, 101, 108, 101, 116, 101, 1, 7, 1, 64, 0, 1, 0, 4, 0, 4, 100, 114, 111, 112, 1, 8, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 4, 1, 21, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 115, 108, 107, 118, 115, 4, 0, 11, 11, 1, 0, 5, 115, 108, 107, 118, 115, 3, 2, 0, 0, 227, 1, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 34, 105, 110, 116, 101, 114, 102, 97, 99, 101, 115, 34, 58, 123, 34, 97, 112, 105, 34, 58, 123, 34, 100, 111, 99, 115, 34, 58, 34, 70, 111, 114, 32, 109, 111, 114, 101, 32, 100, 101, 116, 97, 105, 108, 115, 32, 97, 98, 111, 117, 116, 32, 116, 104, 101, 32, 87, 73, 84, 32, 115, 121, 110, 116, 97, 120, 44, 32, 115, 101, 101, 92, 110, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 87, 101, 98, 65, 115, 115, 101, 109, 98, 108, 121, 47, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 109, 111, 100, 101, 108, 47, 98, 108, 111, 98, 47, 109, 97, 105, 110, 47, 100, 101, 115, 105, 103, 110, 47, 109, 118, 112, 47, 87, 73, 84, 46, 109, 100, 34, 44, 34, 102, 117, 110, 99, 115, 34, 58, 123, 34, 103, 101, 116, 116, 114, 101, 101, 34, 58, 34, 102, 101, 116, 99, 104, 32, 97, 110, 32, 101, 110, 116, 105, 114, 101, 32, 115, 117, 98, 116, 114, 101, 101, 32, 114, 111, 111, 116, 101, 100, 32, 97, 116, 32, 112, 97, 116, 104, 34, 125, 125, 125, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - -#[inline(never)] -#[doc(hidden)] -#[cfg(target_arch = "wasm32")] -pub fn __link_section() {} diff --git a/src/lib.rs b/src/lib.rs index 1a2ed0b..52317b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +// Yes, nightly #![feature(trait_alias)] #![feature(btree_cursors)] #![feature(iter_intersperse)] diff --git a/src/tree.rs b/src/tree.rs index 6ee68dc..19b7920 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -159,26 +159,19 @@ where T : LeafStorage, // because we want storage // } // } -impl From> for serde_json::Value { - fn from(leaf: Leaf) -> Self { - use serde_json::Value; - - match leaf { - Leaf::String(v) => Value::String(v), - Leaf::Number(v) => Value::Number(v.parse().unwrap()), - Leaf::Boolean(v) => Value::Bool(v), - Leaf::Null => Value::Null, - } - } -} - impl From<&Leaf> for serde_json::Value { fn from(leaf: &Leaf) -> Self { use serde_json::Value; match leaf { Leaf::String(v) => Value::String(v.clone()), + + // If this parse fails we should've chosen arbitrary precision at compile + // time. So not much we can do about that here, short of not using + // serde_json::Value as the enum. Which is not worthwhile at this point, + // in this codebase. Leaf::Number(v) => Value::Number(v.parse().unwrap()), + Leaf::Boolean(v) => Value::Bool(*v), Leaf::Null => Value::Null, } @@ -195,7 +188,6 @@ where } } -// type PathMap = std::collections::HashMap; type PathMap = std::collections::BTreeMap; pub struct LeafPaths(pub PathMap>); @@ -666,7 +658,7 @@ mod t { let json = leaf_paths.gettree("root/things/1".into()).unwrap(); assert_eq!(json, r#"{"root":{"things":[{"name":"two"}]}}"#); - let json = leaf_paths.gettree("does/not/exist/5/really".into()).unwrap(); - assert_eq!(json, "null"); + let json = leaf_paths.gettree("does/not/exist/5/really".into()); + assert!(json.is_none()); } } diff --git a/wit/slkvs.wit b/wit/slkvs.wit index 3b3fb45..c63664e 100644 --- a/wit/slkvs.wit +++ b/wit/slkvs.wit @@ -3,6 +3,8 @@ package golem:component; // For more details about the WIT syntax, see // https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md +// naming is a little odd, because these map directly in cli commands, +// and there, it's a PITA to type unnecessary - and _ interface api { add: func(path: string, value: string); get: func(path: string) -> option;