From c9ed43ed16360a4aba4b97da5336dfa6d915a56f Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 27 Sep 2024 15:43:40 -0300 Subject: [PATCH 1/9] serialization: adapting JNI to new serialization schema --- zenoh-jni/Cargo.lock | 73 ++++++++++++++++++++++------------------- zenoh-jni/Cargo.toml | 4 +-- zenoh-jni/src/utils.rs | 9 ++--- zenoh-jni/src/zbytes.rs | 31 +++++++++-------- 4 files changed, 62 insertions(+), 55 deletions(-) diff --git a/zenoh-jni/Cargo.lock b/zenoh-jni/Cargo.lock index 9445c4a13..ff6101533 100644 --- a/zenoh-jni/Cargo.lock +++ b/zenoh-jni/Cargo.lock @@ -231,6 +231,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytemuck" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" + [[package]] name = "byteorder" version = "1.5.0" @@ -933,6 +939,12 @@ dependencies = [ "spin", ] +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "libc" version = "0.2.158" @@ -2460,12 +2472,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "unwrap-infallible" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" - [[package]] name = "unzip-n" version = "0.1.2" @@ -2890,7 +2896,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "ahash", "async-trait", @@ -2917,7 +2923,6 @@ dependencies = [ "tokio-util", "tracing", "uhlc", - "unwrap-infallible", "vec_map", "zenoh-buffers", "zenoh-codec", @@ -2940,7 +2945,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "zenoh-collections", ] @@ -2948,7 +2953,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "tracing", "uhlc", @@ -2959,12 +2964,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "json5", "num_cpus", @@ -2985,7 +2990,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "lazy_static", "tokio", @@ -2996,7 +3001,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "aes", "hmac", @@ -3009,11 +3014,13 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "bincode", + "bytemuck", "flume 0.11.0", "futures", + "leb128", "serde", "tokio", "tracing", @@ -3025,7 +3032,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "hashbrown 0.14.5", "keyed-set", @@ -3039,7 +3046,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -3056,7 +3063,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "flume 0.11.0", @@ -3079,7 +3086,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "base64 0.22.1", @@ -3104,7 +3111,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "socket2", @@ -3121,7 +3128,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "base64 0.22.1", @@ -3148,7 +3155,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "socket2", @@ -3167,7 +3174,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "nix", @@ -3185,7 +3192,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "futures-util", @@ -3205,7 +3212,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "proc-macro2", "quote", @@ -3216,7 +3223,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "git-version", "libloading", @@ -3232,7 +3239,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "const_format", "rand", @@ -3246,7 +3253,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "anyhow", ] @@ -3254,7 +3261,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "lazy_static", "ron", @@ -3267,7 +3274,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "event-listener", "futures", @@ -3280,7 +3287,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "futures", "tokio", @@ -3293,7 +3300,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "crossbeam-utils", @@ -3326,7 +3333,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#a6c69946f7bd40b541ef78c9b7f417d0baa978a3" +source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" dependencies = [ "async-trait", "const_format", diff --git a/zenoh-jni/Cargo.toml b/zenoh-jni/Cargo.toml index 447b67da0..9dcdfd43c 100644 --- a/zenoh-jni/Cargo.toml +++ b/zenoh-jni/Cargo.toml @@ -36,8 +36,8 @@ flume = "0.10.14" uhlc = "0.8.0" json5 = "0.4.1" serde_yaml = "0.9.19" -zenoh = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } -zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } +zenoh = { version = "1.0.0-dev", git = "https://github.com/ZettaScaleLabs/zenoh.git", branch = "serialization_ext2", default-features = false } +zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/ZettaScaleLabs/zenoh.git", branch = "serialization_ext2", default-features = false } tracing = { version = "0.1" , features = ["log"] } [lib] name = "zenoh_jni" diff --git a/zenoh-jni/src/utils.rs b/zenoh-jni/src/utils.rs index 36ed7449d..aa8d01769 100644 --- a/zenoh-jni/src/utils.rs +++ b/zenoh-jni/src/utils.rs @@ -119,13 +119,8 @@ pub(crate) fn decode_reliability(reliability: jint) -> ZResult { } pub(crate) fn bytes_to_java_array<'a>(env: &JNIEnv<'a>, slice: &ZBytes) -> ZResult> { - env.byte_array_from_slice( - slice - .deserialize::>() - .map_err(|err| zerror!("Unable to deserialize slice: {}", err))? - .as_ref(), - ) - .map_err(|err| zerror!(err)) + env.byte_array_from_slice(&slice.to_bytes()) + .map_err(|err| zerror!(err)) } pub(crate) fn slice_to_java_string<'a>(env: &JNIEnv<'a>, slice: &ZSlice) -> ZResult> { diff --git a/zenoh-jni/src/zbytes.rs b/zenoh-jni/src/zbytes.rs index aebf43fc2..978e0e448 100644 --- a/zenoh-jni/src/zbytes.rs +++ b/zenoh-jni/src/zbytes.rs @@ -20,6 +20,7 @@ use jni::{ JNIEnv, }; use zenoh::bytes::ZBytes; +use zenoh_ext::{z_deserialize, z_serialize}; use crate::{errors::ZResult, utils::bytes_to_java_array, zerror}; use crate::{throw_exception, utils::decode_byte_array}; @@ -64,7 +65,7 @@ fn java_map_to_zbytes(env: &mut JNIEnv, map: &JObject) -> jni::errors::Result jobject { || -> ZResult { let payload = decode_byte_array(&env, serialized_map)?; - let zbytes = ZBytes::new(payload); - let deserialization: HashMap, Vec> = zbytes - .deserialize::, Vec>>() - .map_err(|err| zerror!(err))?; + let zbytes = ZBytes::from(payload); + let deserialization: HashMap, Vec> = + z_deserialize(&zbytes).map_err(|err| zerror!(err))?; hashmap_to_java_map(&mut env, &deserialization).map_err(|err| zerror!(err)) }() .unwrap_or_else(|err| { @@ -154,7 +154,7 @@ fn java_list_to_zbytes(env: &mut JNIEnv, list: &JObject) -> jni::errors::Result< let value_bytes = env.convert_byte_array(value_bytes)?; rust_vec.push(value_bytes); } - let zbytes = ZBytes::from_iter(rust_vec); + let zbytes = z_serialize(&rust_vec); Ok(zbytes) } @@ -177,7 +177,7 @@ pub extern "C" fn Java_io_zenoh_jni_JNIZBytes_deserializeIntoListViaJNI( ) -> jobject { || -> ZResult { let payload = decode_byte_array(&env, serialized_list)?; - let zbytes = ZBytes::new(payload); + let zbytes = ZBytes::from(payload); zbytes_to_java_list(&mut env, &zbytes).map_err(|err| zerror!(err)) }() .unwrap_or_else(|err| { @@ -186,12 +186,17 @@ pub extern "C" fn Java_io_zenoh_jni_JNIZBytes_deserializeIntoListViaJNI( }) } -fn zbytes_to_java_list(env: &mut JNIEnv, zbytes: &ZBytes) -> jni::errors::Result { - let array_list = env.new_object("java/util/ArrayList", "()V", &[])?; - let jlist = JList::from_env(env, &array_list)?; - for value in zbytes.iter::>() { - let value = &mut env.byte_array_from_slice(value.unwrap().as_slice())?; //The unwrap is unfallible. - jlist.add(env, value)?; +fn zbytes_to_java_list(env: &mut JNIEnv, zbytes: &ZBytes) -> ZResult { + let array_list = env + .new_object("java/util/ArrayList", "()V", &[]) + .map_err(|err| zerror!(err))?; + let jlist = JList::from_env(env, &array_list).map_err(|err| zerror!(err))?; + let values: Vec> = z_deserialize(zbytes).map_err(|err| zerror!(err))?; + for value in values { + let value = &mut env + .byte_array_from_slice(&value) + .map_err(|err| zerror!(err))?; + jlist.add(env, value).map_err(|err| zerror!(err))?; } Ok(array_list.as_raw()) } From c03453fb1fa5d23e56fee370081954253f0faf84 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 27 Sep 2024 16:47:34 -0300 Subject: [PATCH 2/9] serialization: extracting serialization and deserialization from ZBytes --- examples/src/main/kotlin/io.zenoh/ZBytes.kt | 52 +++--- .../kotlin/io/zenoh/bytes/ZBytes.kt | 169 ------------------ .../kotlin/io/zenoh/bytes/ZDeserialize.kt | 138 ++++++++++++++ .../kotlin/io/zenoh/bytes/ZSerialize.kt | 52 ++++++ .../kotlin/io/zenoh/UserAttachmentTest.kt | 3 +- .../commonTest/kotlin/io/zenoh/ZBytesTest.kt | 62 +++---- 6 files changed, 249 insertions(+), 227 deletions(-) create mode 100644 zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt create mode 100644 zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt diff --git a/examples/src/main/kotlin/io.zenoh/ZBytes.kt b/examples/src/main/kotlin/io.zenoh/ZBytes.kt index 03130550d..fa722f087 100644 --- a/examples/src/main/kotlin/io.zenoh/ZBytes.kt +++ b/examples/src/main/kotlin/io.zenoh/ZBytes.kt @@ -1,8 +1,6 @@ package io.zenoh -import io.zenoh.bytes.IntoZBytes -import io.zenoh.bytes.ZBytes -import io.zenoh.bytes.into +import io.zenoh.bytes.* import java.nio.ByteBuffer import java.nio.ByteOrder import kotlin.reflect.typeOf @@ -16,23 +14,23 @@ fun main() { /** Numeric: byte, short, int, float, double */ val intInput = 1234 var payload = ZBytes.from(intInput) - var intOutput = payload.deserialize().getOrThrow() + var intOutput = deserialize(payload).getOrThrow() check(intInput == intOutput) // Alternatively you can serialize into the type. - payload = ZBytes.serialize(intInput).getOrThrow() - intOutput = payload.deserialize().getOrThrow() + payload = serialize(intInput).getOrThrow() + intOutput = deserialize(payload).getOrThrow() check(intInput == intOutput) // Alternatively, `Numeric.into()`: ZBytes can be used payload = intInput.into() - intOutput = payload.deserialize().getOrThrow() + intOutput = deserialize(payload).getOrThrow() check(intInput == intOutput) // Another example with float val floatInput = 3.1415f payload = ZBytes.from(floatInput) - val floatOutput = payload.deserialize().getOrThrow() + val floatOutput = deserialize(payload).getOrThrow() check(floatInput == floatOutput) /** String serialization and deserialization. */ @@ -41,7 +39,7 @@ fun main() { // Alternatively, you can also call `String.into()` to convert // a string into a ZBytes object: // payload = stringInput.into() - var stringOutput = payload.deserialize().getOrThrow() + var stringOutput = deserialize(payload).getOrThrow() check(stringInput == stringOutput) // For the case of strings, ZBytes::toString() is equivalent: @@ -51,7 +49,7 @@ fun main() { /** ByteArray serialization and deserialization. */ val byteArrayInput = "example".toByteArray() payload = ZBytes.from(byteArrayInput) // Equivalent to `byteArrayInput.into()` - var byteArrayOutput = payload.deserialize().getOrThrow() + var byteArrayOutput = deserialize(payload).getOrThrow() check(byteArrayInput.contentEquals(byteArrayOutput)) // Alternatively, we can directly access the bytes of property of ZBytes: byteArrayOutput = payload.toByteArray() @@ -62,18 +60,18 @@ fun main() { * Supported types: String, ByteArray, ZBytes, Byte, Short, Int, Long, Float and Double. */ val inputList = listOf("sample1", "sample2", "sample3") - payload = ZBytes.serialize(inputList).getOrThrow() - val outputList = payload.deserialize>().getOrThrow() + payload = serialize(inputList).getOrThrow() + val outputList = deserialize>(payload).getOrThrow() check(inputList == outputList) val inputListZBytes = inputList.map { value -> value.into() } - payload = ZBytes.serialize(inputListZBytes).getOrThrow() - val outputListZBytes = payload.deserialize>().getOrThrow() + payload = serialize(inputListZBytes).getOrThrow() + val outputListZBytes = deserialize>(payload).getOrThrow() check(inputListZBytes == outputListZBytes) val inputListByteArray = inputList.map { value -> value.toByteArray() } - payload = ZBytes.serialize(inputListByteArray).getOrThrow() - val outputListByteArray = payload.deserialize>().getOrThrow() + payload = serialize(inputListByteArray).getOrThrow() + val outputListByteArray = deserialize>(payload).getOrThrow() check(compareByteArrayLists(inputListByteArray, outputListByteArray)) /** @@ -82,13 +80,13 @@ fun main() { * Maps with the following Type combinations are supported: String, ByteArray, ZBytes, Byte, Short, Int, Long, Float and Double. */ val inputMap = mapOf("key1" to "value1", "key2" to "value2", "key3" to "value3") - payload = ZBytes.serialize(inputMap).getOrThrow() - val outputMap = payload.deserialize>().getOrThrow() + payload = serialize(inputMap).getOrThrow() + val outputMap = deserialize>(payload).getOrThrow() check(inputMap == outputMap) val combinedInputMap = mapOf("key1" to ZBytes.from("zbytes1"), "key2" to ZBytes.from("zbytes2")) - payload = ZBytes.serialize(combinedInputMap).getOrThrow() - val combinedOutputMap = payload.deserialize>().getOrThrow() + payload = serialize(combinedInputMap).getOrThrow() + val combinedOutputMap = deserialize>(payload).getOrThrow() check(combinedInputMap == combinedOutputMap) /********************************************* @@ -107,27 +105,27 @@ fun main() { * @see MyZBytes */ val inputMyZBytes = MyZBytes("example") - payload = ZBytes.serialize(inputMyZBytes).getOrThrow() + payload = serialize(inputMyZBytes).getOrThrow() val outputMyZBytes = MyZBytes.from(payload) check(inputMyZBytes == outputMyZBytes) /** List of MyZBytes. */ val inputListMyZBytes = inputList.map { value -> MyZBytes(value) } - payload = ZBytes.serialize>(inputListMyZBytes).getOrThrow() - val outputListMyZBytes = payload.deserialize>().getOrThrow().map { zbytes -> MyZBytes.from(zbytes) } + payload = serialize>(inputListMyZBytes).getOrThrow() + val outputListMyZBytes = deserialize>(payload).getOrThrow().map { zbytes -> MyZBytes.from(zbytes) } check(inputListMyZBytes == outputListMyZBytes) /** Map of MyZBytes. */ val inputMapMyZBytes = inputMap.map { (k, v) -> MyZBytes(k) to MyZBytes(v) }.toMap() - payload = ZBytes.serialize>(inputMapMyZBytes).getOrThrow() - val outputMapMyZBytes = payload.deserialize>().getOrThrow() + payload = serialize>(inputMapMyZBytes).getOrThrow() + val outputMapMyZBytes = deserialize>(payload).getOrThrow() .map { (key, value) -> MyZBytes.from(key) to MyZBytes.from(value) }.toMap() check(inputMapMyZBytes == outputMapMyZBytes) /** * Providing a map of deserializers. * - * Alternatively, [ZBytes.deserialize] also accepts a deserializers parameter of type + * Alternatively, [deserialize] also accepts a deserializers parameter of type * `Map>`. That is, a map of types that is associated * to a function receiving a ByteArray, that returns Any. This way, you can provide a series * of deserializer functions that extend the deserialization mechanisms we provide by default. @@ -137,7 +135,7 @@ fun main() { val fooMap = mapOf(Foo("foo1") to Foo("bar1"), Foo("foo2") to Foo("bar2")) val fooMapSerialized = ZBytes.from(serializeFooMap(fooMap)) val deserializersMap = mapOf(typeOf>() to ::deserializeFooMap) - val deserializedFooMap = fooMapSerialized.deserialize>(deserializersMap).getOrThrow() + val deserializedFooMap = deserialize>(fooMapSerialized, deserializersMap).getOrThrow() check(fooMap == deserializedFooMap) } diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt index 1327fc1f4..2149253e9 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt @@ -263,178 +263,9 @@ class ZBytes internal constructor(internal val bytes: ByteArray) : IntoZBytes { return ZBytes(byteArray) } - /** - * Serialize an element of type [T] into a [ZBytes]. - * - * Supported types: - * - [Number]: Byte, Short, Int, Long, Float, Double - * - [String] - * - [ByteArray] - * - [IntoZBytes] - * - Lists and Maps of the above-mentioned types. - * - * @see ZBytes - * @return a [Result] with the serialized [ZBytes]. - */ - inline fun serialize(t: T): Result = runCatching { - return serialize(t, T::class) - } - - fun serialize(t: T, clazz: KClass): Result = runCatching { - val type: KType = when (clazz) { - List::class -> typeOf>() - Map::class -> typeOf>() - else -> clazz.createType() - } - when { - typeOf>().isSupertypeOf(type) -> { - val list = t as List<*> - val zbytesList = list.map { it.into() } - return Result.success(JNIZBytes.serializeIntoList(zbytesList)) - } - - typeOf>().isSupertypeOf(type) -> { - val map = t as Map<*, *> - val zbytesMap = map.map { (k, v) -> k.into() to v.into() }.toMap() - return Result.success(JNIZBytes.serializeIntoMap(zbytesMap)) - } - typeOf().isSupertypeOf(type) -> { - return Result.success((t as Any).into()) - } - - else -> throw IllegalArgumentException("Unsupported type '$type' for serialization.") - } - } } - /** - * Deserialize the [ZBytes] instance into an element of type [T]. - * - * Supported types: - * - [Number]: Byte, Short, Int, Long, Float, Double - * - [String] - * - [ByteArray] - * - Lists and Maps of the above-mentioned types. - * - * - * A map of types and functions for deserialization can also be provided. - * - * For instance: - * ```kotlin - * fun deserializeFoo(zbytes: ZBytes): Foo { - * return Foo(zbytes.toString()) - * } - * - * val foo = Foo("bar") - * val zbytes = ZBytes.serialize(foo) - * val deserialization = zbytes.deserialize(mapOf(typeOf() to ::deserializeFoo)).getOrThrow() - * ``` - * - * In case the provided type isn't associated with any of the functions provided in the [deserializers] map - * (if provided), the deserialization will carry on with the default behavior. - * - * @see ZBytes - * @return a [Result] with the deserialization. - */ - inline fun deserialize( - deserializers: Map> = emptyMap() - ): Result { - val type = typeOf() - val deserializer = deserializers[type] - if (deserializer != null) { - return Result.success(deserializer(this) as T) - } - when { - typeOf>().isSupertypeOf(type) -> { - val itemsClass = type.arguments.firstOrNull()?.type?.jvmErasure - return deserialize(T::class, arg1clazz = itemsClass) - } - typeOf>().isSupertypeOf(type) -> { - val keyClass = type.arguments.getOrNull(0)?.type?.jvmErasure - val valueClass = type.arguments.getOrNull(1)?.type?.jvmErasure - return deserialize(T::class, arg1clazz = keyClass, arg2clazz = valueClass) - } - typeOf().isSupertypeOf(type) -> { - return deserialize(T::class) - } - } - throw IllegalArgumentException("Unsupported type for deserialization: '$type'.") - } - - /** - * Deserialize the [ZBytes] into an element of class [clazz]. - * - * It's generally preferable to use the [ZBytes.deserialize] function with reification, however - * this function is exposed for cases when reification needs to be avoided. - * - * Example: - * ```kotlin - * val list = listOf("value1", "value2", "value3") - * val zbytes = ZBytes.serialize(list).getOrThrow() - * val deserializedList = zbytes.deserialize(clazz = List::class, arg1clazz = String::class).getOrThrow() - * check(list == deserializedList) - * ``` - * - * Supported types: - * - [Number]: Byte, Short, Int, Long, Float, Double - * - [String] - * - [ByteArray] - * - Lists and Maps of the above-mentioned types. - * - * @see [ZBytes.deserialize] - * - * - * @param clazz: the [KClass] of the type to be serialized. - * @param arg1clazz Optional first nested parameter of the provided clazz, for instance when trying to deserialize - * into a `List`, arg1clazz should be set to `String::class`, when trying to deserialize into a - * `Map`, arg1clazz should be set to `Int::class`. Can be null if providing a basic type. - * @param arg2clazz Optional second nested parameter of the provided clazz, to be used for the cases of maps. - * For instance, when trying to deserialize into a `Map`, arg2clazz should be set to `String::class`. - * Can be null if providing a basic type. - */ - @Suppress("UNCHECKED_CAST") - fun deserialize( - clazz: KClass, - arg1clazz: KClass<*>? = null, - arg2clazz: KClass<*>? = null, - ): Result { - val type: KType = when (clazz) { - List::class -> typeOf>() - Map::class -> typeOf>() - else -> clazz.createType() - } - return when { - typeOf>().isSupertypeOf(type) -> { - val typeElement = arg1clazz?.createType() - if (typeElement != null) { - Result.success(JNIZBytes.deserializeIntoList(this).map { it.intoAny(typeElement) } as T) - } else { - Result.failure(IllegalArgumentException("Unsupported list type for deserialization: $type")) - } - } - - typeOf>().isSupertypeOf(type) -> { - val keyType = arg1clazz?.createType() - val valueType = arg2clazz?.createType() - if (keyType != null && valueType != null) { - Result.success(JNIZBytes.deserializeIntoMap(this) - .map { (k, v) -> k.intoAny(keyType) to v.intoAny(valueType) }.toMap() as T - ) - } else { - Result.failure(IllegalArgumentException("Unsupported map type for deserialization: $type")) - } - } - - typeOf().isSupertypeOf(type) -> { - Result.success(this.intoAny(type) as T) - } - - else -> Result.failure(IllegalArgumentException("Unsupported type for deserialization: $type")) - } - } - - fun toByteArray() = bytes fun toByte(): Byte { diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt new file mode 100644 index 000000000..e89083b5f --- /dev/null +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt @@ -0,0 +1,138 @@ +package io.zenoh.bytes + +import io.zenoh.jni.JNIZBytes +import kotlin.reflect.KClass +import kotlin.reflect.KFunction1 +import kotlin.reflect.KType +import kotlin.reflect.full.createType +import kotlin.reflect.full.isSupertypeOf +import kotlin.reflect.jvm.jvmErasure +import kotlin.reflect.typeOf + +/** + * Deserialize the [ZBytes] instance into an element of type [T]. + * + * Supported types: + * - [Number]: Byte, Short, Int, Long, Float, Double + * - [String] + * - [ByteArray] + * - Lists and Maps of the above-mentioned types. + * + * + * A map of types and functions for deserialization can also be provided. + * + * For instance: + * ```kotlin + * fun deserializeFoo(zbytes: ZBytes): Foo { + * return Foo(zbytes.toString()) + * } + * + * val foo = Foo("bar") + * val zbytes = serialize(foo) + * val deserialization = deserialize(zbytes, mapOf(typeOf() to ::deserializeFoo)).getOrThrow() + * ``` + * + * In case the provided type isn't associated with any of the functions provided in the [deserializers] map + * (if provided), the deserialization will carry on with the default behavior. + * + * @see ZBytes + * @return a [Result] with the deserialization. + */ +inline fun deserialize(zbytes: ZBytes, + deserializers: Map> = emptyMap() +): Result { + val type = typeOf() + val deserializer = deserializers[type] + if (deserializer != null) { + return Result.success(deserializer(zbytes) as T) + } + when { + typeOf>().isSupertypeOf(type) -> { + val itemsClass = type.arguments.firstOrNull()?.type?.jvmErasure + return deserialize(zbytes, T::class, arg1clazz = itemsClass) + } + typeOf>().isSupertypeOf(type) -> { + val keyClass = type.arguments.getOrNull(0)?.type?.jvmErasure + val valueClass = type.arguments.getOrNull(1)?.type?.jvmErasure + return deserialize(zbytes, T::class, arg1clazz = keyClass, arg2clazz = valueClass) + } + typeOf().isSupertypeOf(type) -> { + return deserialize(zbytes, T::class) + } + } + throw IllegalArgumentException("Unsupported type for deserialization: '$type'.") +} + +/** + * Deserialize the [ZBytes] into an element of class [clazz]. + * + * It's generally preferable to use the [deserialize] function with reification, however + * this function is exposed for cases when reification needs to be avoided. + * + * Example: + * ```kotlin + * val list = listOf("value1", "value2", "value3") + * val zbytes = serialize(list).getOrThrow() + * val deserializedList = deserialize(zbytes, clazz = List::class, arg1clazz = String::class).getOrThrow() + * check(list == deserializedList) + * ``` + * + * Supported types: + * - [Number]: Byte, Short, Int, Long, Float, Double + * - [String] + * - [ByteArray] + * - Lists and Maps of the above-mentioned types. + * + * @see [deserialize] + * + * + * @param clazz: the [KClass] of the type to be serialized. + * @param arg1clazz Optional first nested parameter of the provided clazz, for instance when trying to deserialize + * into a `List`, arg1clazz should be set to `String::class`, when trying to deserialize into a + * `Map`, arg1clazz should be set to `Int::class`. Can be null if providing a basic type. + * @param arg2clazz Optional second nested parameter of the provided clazz, to be used for the cases of maps. + * For instance, when trying to deserialize into a `Map`, arg2clazz should be set to `String::class`. + * Can be null if providing a basic type. + */ +@Suppress("UNCHECKED_CAST") +fun deserialize( + zbytes: ZBytes, + clazz: KClass, + arg1clazz: KClass<*>? = null, + arg2clazz: KClass<*>? = null, +): Result { + val type: KType = when (clazz) { + List::class -> typeOf>() + Map::class -> typeOf>() + else -> clazz.createType() + } + return when { + typeOf>().isSupertypeOf(type) -> { + val typeElement = arg1clazz?.createType() + if (typeElement != null) { + Result.success(JNIZBytes.deserializeIntoList(zbytes).map { it.intoAny(typeElement) } as T) + } else { + Result.failure(IllegalArgumentException("Unsupported list type for deserialization: $type")) + } + } + + typeOf>().isSupertypeOf(type) -> { + val keyType = arg1clazz?.createType() + val valueType = arg2clazz?.createType() + if (keyType != null && valueType != null) { + Result.success( + JNIZBytes.deserializeIntoMap(zbytes) + .map { (k, v) -> k.intoAny(keyType) to v.intoAny(valueType) }.toMap() as T + ) + } else { + Result.failure(IllegalArgumentException("Unsupported map type for deserialization: $type")) + } + } + + typeOf().isSupertypeOf(type) -> { + Result.success(zbytes.intoAny(type) as T) + } + + else -> Result.failure(IllegalArgumentException("Unsupported type for deserialization: $type")) + } +} diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt new file mode 100644 index 000000000..c318e9edc --- /dev/null +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt @@ -0,0 +1,52 @@ +package io.zenoh.bytes + +import io.zenoh.jni.JNIZBytes +import kotlin.reflect.KClass +import kotlin.reflect.KType +import kotlin.reflect.full.createType +import kotlin.reflect.full.isSupertypeOf +import kotlin.reflect.typeOf + +/** + * Serialize an element of type [T] into a [ZBytes]. + * + * Supported types: + * - [Number]: Byte, Short, Int, Long, Float, Double + * - [String] + * - [ByteArray] + * - [IntoZBytes] + * - Lists and Maps of the above-mentioned types. + * + * @see ZBytes + * @return a [Result] with the serialized [ZBytes]. + */ +inline fun serialize(t: T): Result = runCatching { + return serialize(t, T::class) +} + +fun serialize(t: T, clazz: KClass): Result = runCatching { + val type: KType = when (clazz) { + List::class -> typeOf>() + Map::class -> typeOf>() + else -> clazz.createType() + } + when { + typeOf>().isSupertypeOf(type) -> { + val list = t as List<*> + val zbytesList = list.map { it.into() } + return Result.success(JNIZBytes.serializeIntoList(zbytesList)) + } + + typeOf>().isSupertypeOf(type) -> { + val map = t as Map<*, *> + val zbytesMap = map.map { (k, v) -> k.into() to v.into() }.toMap() + return Result.success(JNIZBytes.serializeIntoMap(zbytesMap)) + } + + typeOf().isSupertypeOf(type) -> { + return Result.success((t as Any).into()) + } + + else -> throw IllegalArgumentException("Unsupported type '$type' for serialization.") + } +} diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt index 25355564b..d0a59706a 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt @@ -17,6 +17,7 @@ package io.zenoh import io.zenoh.keyexpr.KeyExpr import io.zenoh.keyexpr.intoKeyExpr import io.zenoh.bytes.ZBytes +import io.zenoh.bytes.deserialize import io.zenoh.bytes.into import io.zenoh.config.Config import io.zenoh.query.Reply @@ -79,7 +80,7 @@ class UserAttachmentTest { assertNotNull(receivedSample) { val receivedAttachment = it.attachment!! - assertEquals(attachment, receivedAttachment.deserialize().getOrNull()) + assertEquals(attachment, deserialize(receivedAttachment).getOrNull()) } } diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt index bfc98b173..7d0624bd0 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt @@ -15,7 +15,9 @@ package io.zenoh import io.zenoh.bytes.ZBytes +import io.zenoh.bytes.deserialize import io.zenoh.bytes.into +import io.zenoh.bytes.serialize import org.junit.jupiter.api.Assertions.assertArrayEquals import org.junit.jupiter.api.Assertions.assertEquals @@ -175,8 +177,8 @@ class ZBytesTests { val originalItem = testCase.originalItem val clazz = testCase.clazz - val bytes = ZBytes.serialize(originalItem, clazz = clazz).getOrThrow() - val deserializedItem = bytes.deserialize(clazz = clazz).getOrThrow() + val bytes = serialize(originalItem, clazz = clazz).getOrThrow() + val deserializedItem = deserialize(bytes, clazz = clazz).getOrThrow() if (originalItem is ByteArray) { assertArrayEquals(originalItem, deserializedItem as ByteArray) @@ -191,9 +193,9 @@ class ZBytesTests { val originalList = testCase.originalList val itemClass = testCase.itemclazz - val bytes = ZBytes.serialize(originalList).getOrThrow() + val bytes = serialize(originalList).getOrThrow() - val deserializedList = bytes.deserialize(clazz = List::class, arg1clazz = itemClass).getOrThrow() + val deserializedList = deserialize(bytes, clazz = List::class, arg1clazz = itemClass).getOrThrow() if (originalList.isNotEmpty() && originalList[0] is ByteArray) { originalList.forEachIndexed { index, value -> @@ -211,9 +213,10 @@ class ZBytesTests { val keyClass = testCase.keyclazz val valueClass = testCase.valueclazz - val bytes = ZBytes.serialize(originalMap).getOrThrow() + val bytes = serialize(originalMap).getOrThrow() - val deserializedMap = bytes.deserialize( + val deserializedMap = deserialize( + bytes, clazz = Map::class, arg1clazz = keyClass, arg2clazz = valueClass @@ -261,30 +264,29 @@ class ZBytesTests { typeOf>>() to ::deserializeIntoListOfPairs, ) - val deserializedMap = serializedBytes.deserialize>(customDeserializers).getOrThrow() + val deserializedMap = deserialize>(serializedBytes, customDeserializers).getOrThrow() assertEquals(zbytesMap, deserializedMap) - val deserializedMap2 = serializedBytes.deserialize>(customDeserializers).getOrThrow() + val deserializedMap2 = deserialize>(serializedBytes, customDeserializers).getOrThrow() assertEquals(stringMap, deserializedMap2) val intMapBytes = serializeIntoIntMap(intMap) - val deserializedMap3 = intMapBytes.deserialize>(customDeserializers).getOrThrow() + val deserializedMap3 = deserialize>(intMapBytes, customDeserializers).getOrThrow() assertEquals(intMap, deserializedMap3) val serializedZBytesList = serializeZBytesList(zbytesList) - val deserializedList = serializedZBytesList.deserialize>(customDeserializers).getOrThrow() + val deserializedList = deserialize>(serializedZBytesList, customDeserializers).getOrThrow() assertEquals(zbytesList, deserializedList) val serializedZBytesPairList = serializeZBytesMap(zbytesListOfPairs.toMap()) - val deserializedZBytesPairList = - serializedZBytesPairList.deserialize>>(customDeserializers).getOrThrow() + val deserializedZBytesPairList = deserialize>>(serializedZBytesPairList, customDeserializers).getOrThrow() assertEquals(zbytesListOfPairs, deserializedZBytesPairList) } /** - * A series of tests to verify the correct functioning of the [ZBytes.deserialize] function. + * A series of tests to verify the correct functioning of the [deserialize] function. * - * The [ZBytes.deserialize] function with reification can not be tested in a parametrized fashion because + * The [deserialize] function with reification can not be tested in a parametrized fashion because * it uses reified parameters which causes the testing framework (designed for Java) to fail to properly * set up the tests. */ @@ -297,50 +299,50 @@ class ZBytesTests { /** Numeric: byte, short, int, float, double */ val intInput = 1234 var payload = ZBytes.from(intInput) - val intOutput = payload.deserialize().getOrThrow() + val intOutput = deserialize(payload).getOrThrow() assertEquals(intInput, intOutput) // Another example with float val floatInput = 3.1415f payload = ZBytes.from(floatInput) - val floatOutput = payload.deserialize().getOrThrow() + val floatOutput = deserialize(payload).getOrThrow() assertEquals(floatInput, floatOutput) /** String serialization and deserialization. */ val stringInput = "example" payload = ZBytes.from(stringInput) - val stringOutput = payload.deserialize().getOrThrow() + val stringOutput = deserialize(payload).getOrThrow() assertEquals(stringInput, stringOutput) /** ByteArray serialization and deserialization. */ val byteArrayInput = "example".toByteArray() payload = ZBytes.from(byteArrayInput) // Equivalent to `byteArrayInput.into()` - val byteArrayOutput = payload.deserialize().getOrThrow() + val byteArrayOutput = deserialize(payload).getOrThrow() assertTrue(byteArrayInput.contentEquals(byteArrayOutput)) val inputList = listOf("sample1", "sample2", "sample3") - payload = ZBytes.serialize(inputList).getOrThrow() - val outputList = payload.deserialize>().getOrThrow() + payload = serialize(inputList).getOrThrow() + val outputList = deserialize>(payload).getOrThrow() assertEquals(inputList, outputList) val inputListZBytes = inputList.map { value -> value.into() } - payload = ZBytes.serialize(inputListZBytes).getOrThrow() - val outputListZBytes = payload.deserialize>().getOrThrow() + payload = serialize(inputListZBytes).getOrThrow() + val outputListZBytes = deserialize>(payload).getOrThrow() assertEquals(inputListZBytes, outputListZBytes) val inputListByteArray = inputList.map { value -> value.toByteArray() } - payload = ZBytes.serialize(inputListByteArray).getOrThrow() - val outputListByteArray = payload.deserialize>().getOrThrow() + payload = serialize(inputListByteArray).getOrThrow() + val outputListByteArray = deserialize>(payload).getOrThrow() assertTrue(compareByteArrayLists(inputListByteArray, outputListByteArray)) val inputMap = mapOf("key1" to "value1", "key2" to "value2", "key3" to "value3") - payload = ZBytes.serialize(inputMap).getOrThrow() - val outputMap = payload.deserialize>().getOrThrow() + payload = serialize(inputMap).getOrThrow() + val outputMap = deserialize>(payload).getOrThrow() assertEquals(inputMap, outputMap) val combinedInputMap = mapOf("key1" to ZBytes.from("zbytes1"), "key2" to ZBytes.from("zbytes2")) - payload = ZBytes.serialize(combinedInputMap).getOrThrow() - val combinedOutputMap = payload.deserialize>().getOrThrow() + payload = serialize(combinedInputMap).getOrThrow() + val combinedOutputMap = deserialize>(payload).getOrThrow() assertEquals(combinedInputMap, combinedOutputMap) /********************************************* @@ -353,7 +355,7 @@ class ZBytesTests { val fooMap = mapOf(Foo("foo1") to Foo("bar1"), Foo("foo2") to Foo("bar2")) val fooMapSerialized = ZBytes.from(serializeFooMap(fooMap)) val deserializersMap = mapOf(typeOf>() to ::deserializeFooMap) - val deserializedFooMap = fooMapSerialized.deserialize>(deserializersMap).getOrThrow() + val deserializedFooMap = deserialize>(fooMapSerialized, deserializersMap).getOrThrow() assertEquals(fooMap, deserializedFooMap) } @@ -480,7 +482,7 @@ class ZBytesTests { private fun deserializeIntoIntMap(serializerMap: ZBytes): Map { return deserializeIntoZBytesMap(serializerMap).map { (k, v) -> - k.deserialize().getOrThrow() to v.deserialize().getOrThrow() + deserialize(k).getOrThrow() to deserialize(v).getOrThrow() }.toMap() } From 3731e64bb30a457d6e55a307a8c061594a0a889c Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 27 Sep 2024 17:34:09 -0300 Subject: [PATCH 3/9] serialization: updating zbytes kdoc --- .../kotlin/io/zenoh/bytes/ZBytes.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt index 2149253e9..bd77d3e7c 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt @@ -57,7 +57,7 @@ import kotlin.reflect.typeOf * * using the serialize syntax: * ```kotlin * val exampleInt: Int = 256 - * val zbytes: ZBytes = ZBytes.serialize(exampleInt).getOrThrow() + * val zbytes: ZBytes = serialize(exampleInt).getOrThrow() * ``` * This approach works as well for the other mentioned types. * @@ -72,7 +72,7 @@ import kotlin.reflect.typeOf * The serialize syntax must be used: * ```kotlin * val myList = listOf(1, 2, 5, 8, 13, 21) - * val zbytes = ZBytes.serialize>(myList).getOrThrow() + * val zbytes = serialize>(myList).getOrThrow() * ``` * * ## Maps @@ -85,7 +85,7 @@ import kotlin.reflect.typeOf * * ```kotlin * val myMap: Map = mapOf("foo" to 1, "bar" to 2) - * val zbytes = ZBytes.serialize>(myMap).getOrThrow() + * val zbytes = serialize>(myMap).getOrThrow() * ``` * * # Deserialization @@ -118,7 +118,7 @@ import kotlin.reflect.typeOf * ```kotlin * val exampleInt: Int = 256 * val zbytes: ZBytes = exampleInt.into() - * val deserializedInt = zbytes.deserialize().getOrThrow() + * val deserializedInt = deserialize(zbytes).getOrThrow() * ``` * * ## Lists @@ -131,8 +131,8 @@ import kotlin.reflect.typeOf * To deserialize into a list, we need to use the deserialize syntax as follows: * ```kotlin * val inputList = listOf("sample1", "sample2", "sample3") - * payload = ZBytes.serialize(inputList).getOrThrow() - * val outputList = payload.deserialize>().getOrThrow() + * payload = serialize(inputList).getOrThrow() + * val outputList = deserialize>(payload).getOrThrow() * ``` * * ## Maps @@ -144,8 +144,8 @@ import kotlin.reflect.typeOf * * ```kotlin * val inputMap = mapOf("key1" to "value1", "key2" to "value2", "key3" to "value3") - * payload = ZBytes.serialize(inputMap).getOrThrow() - * val outputMap = payload.deserialize>().getOrThrow() + * payload = serialize(inputMap).getOrThrow() + * val outputMap = deserialize>(payload).getOrThrow() * check(inputMap == outputMap) * ``` * @@ -167,14 +167,14 @@ import kotlin.reflect.typeOf * This way, we can do: * ```kotlin * val foo = Foo("bar") - * val serialization = ZBytes.serialize(foo).getOrThrow() + * val serialization = serialize(foo).getOrThrow() * ``` * * Implementing the [IntoZBytes] interface on a class enables the possibility of serializing lists and maps * of that type, for instance: * ```kotlin * val list = listOf(Foo("bar"), Foo("buz"), Foo("fizz")) - * val zbytes = ZBytes.serialize>(list) + * val zbytes = serialize>(list) * ``` * * ## Deserialization @@ -187,20 +187,20 @@ import kotlin.reflect.typeOf * * ```kotlin * val inputFoo = Foo("example") - * payload = ZBytes.serialize(inputFoo).getOrThrow() + * payload = serialize(inputFoo).getOrThrow() * val outputFoo = Foo.from(payload) * check(inputFoo == outputFoo) * * // List of Foo. * val inputListFoo = inputList.map { value -> Foo(value) } - * payload = ZBytes.serialize>(inputListFoo).getOrThrow() - * val outputListFoo = payload.deserialize>().getOrThrow().map { zbytes -> Foo.from(zbytes) } + * payload = serialize>(inputListFoo).getOrThrow() + * val outputListFoo = deserialize>(payload).getOrThrow().map { zbytes -> Foo.from(zbytes) } * check(inputListFoo == outputListFoo) * * // Map of Foo. * val inputMapFoo = inputMap.map { (k, v) -> Foo(k) to Foo(v) }.toMap() - * payload = ZBytes.serialize>(inputMapFoo).getOrThrow() - * val outputMapFoo = payload.deserialize>().getOrThrow() + * payload = serialize>(inputMapFoo).getOrThrow() + * val outputMapFoo = deserialize>(payload).getOrThrow() * .map { (key, value) -> Foo.from(key) to Foo.from(value) }.toMap() * check(inputMapFoo == outputMapFoo) * ``` @@ -220,8 +220,8 @@ import kotlin.reflect.typeOf * } * * val foo = Foo("bar") - * val zbytes = ZBytes.serialize(foo) - * val deserialization = zbytes.deserialize(mapOf(typeOf() to ::deserializeFoo)).getOrThrow() + * val zbytes = serialize(foo) + * val deserialization = deserialize(zbytes, mapOf(typeOf() to ::deserializeFoo)).getOrThrow() * ``` */ class ZBytes internal constructor(internal val bytes: ByteArray) : IntoZBytes { From 4b3bcf5d7855034441dc60bfc08d21089f74e0b3 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 27 Sep 2024 18:33:40 -0300 Subject: [PATCH 4/9] serialization: moving ZSerialize and ZDeserialize into an ext package, renaming serialize into zSerialize and deserialize into zDeserialize. --- examples/src/main/kotlin/io.zenoh/ZBytes.kt | 50 ++++++++------- .../kotlin/io/zenoh/bytes/ZBytes.kt | 4 -- .../io/zenoh/{bytes => ext}/ZDeserialize.kt | 20 +++--- .../io/zenoh/{bytes => ext}/ZSerialize.kt | 10 +-- .../kotlin/io/zenoh/UserAttachmentTest.kt | 4 +- .../commonTest/kotlin/io/zenoh/ZBytesTest.kt | 62 +++++++++---------- 6 files changed, 76 insertions(+), 74 deletions(-) rename zenoh-kotlin/src/commonMain/kotlin/io/zenoh/{bytes => ext}/ZDeserialize.kt (88%) rename zenoh-kotlin/src/commonMain/kotlin/io/zenoh/{bytes => ext}/ZSerialize.kt (83%) diff --git a/examples/src/main/kotlin/io.zenoh/ZBytes.kt b/examples/src/main/kotlin/io.zenoh/ZBytes.kt index fa722f087..7803a971b 100644 --- a/examples/src/main/kotlin/io.zenoh/ZBytes.kt +++ b/examples/src/main/kotlin/io.zenoh/ZBytes.kt @@ -1,6 +1,8 @@ package io.zenoh import io.zenoh.bytes.* +import io.zenoh.ext.zDeserialize +import io.zenoh.ext.zSerialize import java.nio.ByteBuffer import java.nio.ByteOrder import kotlin.reflect.typeOf @@ -14,23 +16,23 @@ fun main() { /** Numeric: byte, short, int, float, double */ val intInput = 1234 var payload = ZBytes.from(intInput) - var intOutput = deserialize(payload).getOrThrow() + var intOutput = zDeserialize(payload).getOrThrow() check(intInput == intOutput) // Alternatively you can serialize into the type. - payload = serialize(intInput).getOrThrow() - intOutput = deserialize(payload).getOrThrow() + payload = zSerialize(intInput).getOrThrow() + intOutput = zDeserialize(payload).getOrThrow() check(intInput == intOutput) // Alternatively, `Numeric.into()`: ZBytes can be used payload = intInput.into() - intOutput = deserialize(payload).getOrThrow() + intOutput = zDeserialize(payload).getOrThrow() check(intInput == intOutput) // Another example with float val floatInput = 3.1415f payload = ZBytes.from(floatInput) - val floatOutput = deserialize(payload).getOrThrow() + val floatOutput = zDeserialize(payload).getOrThrow() check(floatInput == floatOutput) /** String serialization and deserialization. */ @@ -39,7 +41,7 @@ fun main() { // Alternatively, you can also call `String.into()` to convert // a string into a ZBytes object: // payload = stringInput.into() - var stringOutput = deserialize(payload).getOrThrow() + var stringOutput = zDeserialize(payload).getOrThrow() check(stringInput == stringOutput) // For the case of strings, ZBytes::toString() is equivalent: @@ -49,7 +51,7 @@ fun main() { /** ByteArray serialization and deserialization. */ val byteArrayInput = "example".toByteArray() payload = ZBytes.from(byteArrayInput) // Equivalent to `byteArrayInput.into()` - var byteArrayOutput = deserialize(payload).getOrThrow() + var byteArrayOutput = zDeserialize(payload).getOrThrow() check(byteArrayInput.contentEquals(byteArrayOutput)) // Alternatively, we can directly access the bytes of property of ZBytes: byteArrayOutput = payload.toByteArray() @@ -60,18 +62,18 @@ fun main() { * Supported types: String, ByteArray, ZBytes, Byte, Short, Int, Long, Float and Double. */ val inputList = listOf("sample1", "sample2", "sample3") - payload = serialize(inputList).getOrThrow() - val outputList = deserialize>(payload).getOrThrow() + payload = zSerialize(inputList).getOrThrow() + val outputList = zDeserialize>(payload).getOrThrow() check(inputList == outputList) val inputListZBytes = inputList.map { value -> value.into() } - payload = serialize(inputListZBytes).getOrThrow() - val outputListZBytes = deserialize>(payload).getOrThrow() + payload = zSerialize(inputListZBytes).getOrThrow() + val outputListZBytes = zDeserialize>(payload).getOrThrow() check(inputListZBytes == outputListZBytes) val inputListByteArray = inputList.map { value -> value.toByteArray() } - payload = serialize(inputListByteArray).getOrThrow() - val outputListByteArray = deserialize>(payload).getOrThrow() + payload = zSerialize(inputListByteArray).getOrThrow() + val outputListByteArray = zDeserialize>(payload).getOrThrow() check(compareByteArrayLists(inputListByteArray, outputListByteArray)) /** @@ -80,13 +82,13 @@ fun main() { * Maps with the following Type combinations are supported: String, ByteArray, ZBytes, Byte, Short, Int, Long, Float and Double. */ val inputMap = mapOf("key1" to "value1", "key2" to "value2", "key3" to "value3") - payload = serialize(inputMap).getOrThrow() - val outputMap = deserialize>(payload).getOrThrow() + payload = zSerialize(inputMap).getOrThrow() + val outputMap = zDeserialize>(payload).getOrThrow() check(inputMap == outputMap) val combinedInputMap = mapOf("key1" to ZBytes.from("zbytes1"), "key2" to ZBytes.from("zbytes2")) - payload = serialize(combinedInputMap).getOrThrow() - val combinedOutputMap = deserialize>(payload).getOrThrow() + payload = zSerialize(combinedInputMap).getOrThrow() + val combinedOutputMap = zDeserialize>(payload).getOrThrow() check(combinedInputMap == combinedOutputMap) /********************************************* @@ -105,27 +107,27 @@ fun main() { * @see MyZBytes */ val inputMyZBytes = MyZBytes("example") - payload = serialize(inputMyZBytes).getOrThrow() + payload = zSerialize(inputMyZBytes).getOrThrow() val outputMyZBytes = MyZBytes.from(payload) check(inputMyZBytes == outputMyZBytes) /** List of MyZBytes. */ val inputListMyZBytes = inputList.map { value -> MyZBytes(value) } - payload = serialize>(inputListMyZBytes).getOrThrow() - val outputListMyZBytes = deserialize>(payload).getOrThrow().map { zbytes -> MyZBytes.from(zbytes) } + payload = zSerialize>(inputListMyZBytes).getOrThrow() + val outputListMyZBytes = zDeserialize>(payload).getOrThrow().map { zbytes -> MyZBytes.from(zbytes) } check(inputListMyZBytes == outputListMyZBytes) /** Map of MyZBytes. */ val inputMapMyZBytes = inputMap.map { (k, v) -> MyZBytes(k) to MyZBytes(v) }.toMap() - payload = serialize>(inputMapMyZBytes).getOrThrow() - val outputMapMyZBytes = deserialize>(payload).getOrThrow() + payload = zSerialize>(inputMapMyZBytes).getOrThrow() + val outputMapMyZBytes = zDeserialize>(payload).getOrThrow() .map { (key, value) -> MyZBytes.from(key) to MyZBytes.from(value) }.toMap() check(inputMapMyZBytes == outputMapMyZBytes) /** * Providing a map of deserializers. * - * Alternatively, [deserialize] also accepts a deserializers parameter of type + * Alternatively, [zDeserialize] also accepts a deserializers parameter of type * `Map>`. That is, a map of types that is associated * to a function receiving a ByteArray, that returns Any. This way, you can provide a series * of deserializer functions that extend the deserialization mechanisms we provide by default. @@ -135,7 +137,7 @@ fun main() { val fooMap = mapOf(Foo("foo1") to Foo("bar1"), Foo("foo2") to Foo("bar2")) val fooMapSerialized = ZBytes.from(serializeFooMap(fooMap)) val deserializersMap = mapOf(typeOf>() to ::deserializeFooMap) - val deserializedFooMap = deserialize>(fooMapSerialized, deserializersMap).getOrThrow() + val deserializedFooMap = zDeserialize>(fooMapSerialized, deserializersMap).getOrThrow() check(fooMap == deserializedFooMap) } diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt index bd77d3e7c..e186da233 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt @@ -15,14 +15,10 @@ package io.zenoh.bytes import io.zenoh.exceptions.ZError -import io.zenoh.jni.JNIZBytes import java.nio.ByteBuffer import java.nio.ByteOrder -import kotlin.reflect.KClass -import kotlin.reflect.KFunction1 import kotlin.reflect.KType import kotlin.reflect.full.* -import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf /** diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt similarity index 88% rename from zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt rename to zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt index e89083b5f..ab6738cdf 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZDeserialize.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt @@ -1,5 +1,7 @@ -package io.zenoh.bytes +package io.zenoh.ext +import io.zenoh.bytes.ZBytes +import io.zenoh.bytes.intoAny import io.zenoh.jni.JNIZBytes import kotlin.reflect.KClass import kotlin.reflect.KFunction1 @@ -38,8 +40,8 @@ import kotlin.reflect.typeOf * @see ZBytes * @return a [Result] with the deserialization. */ -inline fun deserialize(zbytes: ZBytes, - deserializers: Map> = emptyMap() +inline fun zDeserialize(zbytes: ZBytes, + deserializers: Map> = emptyMap() ): Result { val type = typeOf() val deserializer = deserializers[type] @@ -49,15 +51,15 @@ inline fun deserialize(zbytes: ZBytes, when { typeOf>().isSupertypeOf(type) -> { val itemsClass = type.arguments.firstOrNull()?.type?.jvmErasure - return deserialize(zbytes, T::class, arg1clazz = itemsClass) + return zDeserialize(zbytes, T::class, arg1clazz = itemsClass) } typeOf>().isSupertypeOf(type) -> { val keyClass = type.arguments.getOrNull(0)?.type?.jvmErasure val valueClass = type.arguments.getOrNull(1)?.type?.jvmErasure - return deserialize(zbytes, T::class, arg1clazz = keyClass, arg2clazz = valueClass) + return zDeserialize(zbytes, T::class, arg1clazz = keyClass, arg2clazz = valueClass) } typeOf().isSupertypeOf(type) -> { - return deserialize(zbytes, T::class) + return zDeserialize(zbytes, T::class) } } throw IllegalArgumentException("Unsupported type for deserialization: '$type'.") @@ -66,7 +68,7 @@ inline fun deserialize(zbytes: ZBytes, /** * Deserialize the [ZBytes] into an element of class [clazz]. * - * It's generally preferable to use the [deserialize] function with reification, however + * It's generally preferable to use the [zDeserialize] function with reification, however * this function is exposed for cases when reification needs to be avoided. * * Example: @@ -83,7 +85,7 @@ inline fun deserialize(zbytes: ZBytes, * - [ByteArray] * - Lists and Maps of the above-mentioned types. * - * @see [deserialize] + * @see [zDeserialize] * * * @param clazz: the [KClass] of the type to be serialized. @@ -95,7 +97,7 @@ inline fun deserialize(zbytes: ZBytes, * Can be null if providing a basic type. */ @Suppress("UNCHECKED_CAST") -fun deserialize( +fun zDeserialize( zbytes: ZBytes, clazz: KClass, arg1clazz: KClass<*>? = null, diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZSerialize.kt similarity index 83% rename from zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt rename to zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZSerialize.kt index c318e9edc..71a0a3243 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZSerialize.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZSerialize.kt @@ -1,5 +1,7 @@ -package io.zenoh.bytes +package io.zenoh.ext +import io.zenoh.bytes.ZBytes +import io.zenoh.bytes.into import io.zenoh.jni.JNIZBytes import kotlin.reflect.KClass import kotlin.reflect.KType @@ -20,11 +22,11 @@ import kotlin.reflect.typeOf * @see ZBytes * @return a [Result] with the serialized [ZBytes]. */ -inline fun serialize(t: T): Result = runCatching { - return serialize(t, T::class) +inline fun zSerialize(t: T): Result = runCatching { + return zSerialize(t, T::class) } -fun serialize(t: T, clazz: KClass): Result = runCatching { +fun zSerialize(t: T, clazz: KClass): Result = runCatching { val type: KType = when (clazz) { List::class -> typeOf>() Map::class -> typeOf>() diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt index d0a59706a..98cb0eda2 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/UserAttachmentTest.kt @@ -17,7 +17,7 @@ package io.zenoh import io.zenoh.keyexpr.KeyExpr import io.zenoh.keyexpr.intoKeyExpr import io.zenoh.bytes.ZBytes -import io.zenoh.bytes.deserialize +import io.zenoh.ext.zDeserialize import io.zenoh.bytes.into import io.zenoh.config.Config import io.zenoh.query.Reply @@ -80,7 +80,7 @@ class UserAttachmentTest { assertNotNull(receivedSample) { val receivedAttachment = it.attachment!! - assertEquals(attachment, deserialize(receivedAttachment).getOrNull()) + assertEquals(attachment, zDeserialize(receivedAttachment).getOrNull()) } } diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt index 7d0624bd0..e211acb05 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt @@ -15,9 +15,9 @@ package io.zenoh import io.zenoh.bytes.ZBytes -import io.zenoh.bytes.deserialize +import io.zenoh.ext.zDeserialize import io.zenoh.bytes.into -import io.zenoh.bytes.serialize +import io.zenoh.ext.zSerialize import org.junit.jupiter.api.Assertions.assertArrayEquals import org.junit.jupiter.api.Assertions.assertEquals @@ -177,8 +177,8 @@ class ZBytesTests { val originalItem = testCase.originalItem val clazz = testCase.clazz - val bytes = serialize(originalItem, clazz = clazz).getOrThrow() - val deserializedItem = deserialize(bytes, clazz = clazz).getOrThrow() + val bytes = zSerialize(originalItem, clazz = clazz).getOrThrow() + val deserializedItem = zDeserialize(bytes, clazz = clazz).getOrThrow() if (originalItem is ByteArray) { assertArrayEquals(originalItem, deserializedItem as ByteArray) @@ -193,9 +193,9 @@ class ZBytesTests { val originalList = testCase.originalList val itemClass = testCase.itemclazz - val bytes = serialize(originalList).getOrThrow() + val bytes = zSerialize(originalList).getOrThrow() - val deserializedList = deserialize(bytes, clazz = List::class, arg1clazz = itemClass).getOrThrow() + val deserializedList = zDeserialize(bytes, clazz = List::class, arg1clazz = itemClass).getOrThrow() if (originalList.isNotEmpty() && originalList[0] is ByteArray) { originalList.forEachIndexed { index, value -> @@ -213,9 +213,9 @@ class ZBytesTests { val keyClass = testCase.keyclazz val valueClass = testCase.valueclazz - val bytes = serialize(originalMap).getOrThrow() + val bytes = zSerialize(originalMap).getOrThrow() - val deserializedMap = deserialize( + val deserializedMap = zDeserialize( bytes, clazz = Map::class, arg1clazz = keyClass, @@ -264,29 +264,29 @@ class ZBytesTests { typeOf>>() to ::deserializeIntoListOfPairs, ) - val deserializedMap = deserialize>(serializedBytes, customDeserializers).getOrThrow() + val deserializedMap = zDeserialize>(serializedBytes, customDeserializers).getOrThrow() assertEquals(zbytesMap, deserializedMap) - val deserializedMap2 = deserialize>(serializedBytes, customDeserializers).getOrThrow() + val deserializedMap2 = zDeserialize>(serializedBytes, customDeserializers).getOrThrow() assertEquals(stringMap, deserializedMap2) val intMapBytes = serializeIntoIntMap(intMap) - val deserializedMap3 = deserialize>(intMapBytes, customDeserializers).getOrThrow() + val deserializedMap3 = zDeserialize>(intMapBytes, customDeserializers).getOrThrow() assertEquals(intMap, deserializedMap3) val serializedZBytesList = serializeZBytesList(zbytesList) - val deserializedList = deserialize>(serializedZBytesList, customDeserializers).getOrThrow() + val deserializedList = zDeserialize>(serializedZBytesList, customDeserializers).getOrThrow() assertEquals(zbytesList, deserializedList) val serializedZBytesPairList = serializeZBytesMap(zbytesListOfPairs.toMap()) - val deserializedZBytesPairList = deserialize>>(serializedZBytesPairList, customDeserializers).getOrThrow() + val deserializedZBytesPairList = zDeserialize>>(serializedZBytesPairList, customDeserializers).getOrThrow() assertEquals(zbytesListOfPairs, deserializedZBytesPairList) } /** - * A series of tests to verify the correct functioning of the [deserialize] function. + * A series of tests to verify the correct functioning of the [zDeserialize] function. * - * The [deserialize] function with reification can not be tested in a parametrized fashion because + * The [zDeserialize] function with reification can not be tested in a parametrized fashion because * it uses reified parameters which causes the testing framework (designed for Java) to fail to properly * set up the tests. */ @@ -299,50 +299,50 @@ class ZBytesTests { /** Numeric: byte, short, int, float, double */ val intInput = 1234 var payload = ZBytes.from(intInput) - val intOutput = deserialize(payload).getOrThrow() + val intOutput = zDeserialize(payload).getOrThrow() assertEquals(intInput, intOutput) // Another example with float val floatInput = 3.1415f payload = ZBytes.from(floatInput) - val floatOutput = deserialize(payload).getOrThrow() + val floatOutput = zDeserialize(payload).getOrThrow() assertEquals(floatInput, floatOutput) /** String serialization and deserialization. */ val stringInput = "example" payload = ZBytes.from(stringInput) - val stringOutput = deserialize(payload).getOrThrow() + val stringOutput = zDeserialize(payload).getOrThrow() assertEquals(stringInput, stringOutput) /** ByteArray serialization and deserialization. */ val byteArrayInput = "example".toByteArray() payload = ZBytes.from(byteArrayInput) // Equivalent to `byteArrayInput.into()` - val byteArrayOutput = deserialize(payload).getOrThrow() + val byteArrayOutput = zDeserialize(payload).getOrThrow() assertTrue(byteArrayInput.contentEquals(byteArrayOutput)) val inputList = listOf("sample1", "sample2", "sample3") - payload = serialize(inputList).getOrThrow() - val outputList = deserialize>(payload).getOrThrow() + payload = zSerialize(inputList).getOrThrow() + val outputList = zDeserialize>(payload).getOrThrow() assertEquals(inputList, outputList) val inputListZBytes = inputList.map { value -> value.into() } - payload = serialize(inputListZBytes).getOrThrow() - val outputListZBytes = deserialize>(payload).getOrThrow() + payload = zSerialize(inputListZBytes).getOrThrow() + val outputListZBytes = zDeserialize>(payload).getOrThrow() assertEquals(inputListZBytes, outputListZBytes) val inputListByteArray = inputList.map { value -> value.toByteArray() } - payload = serialize(inputListByteArray).getOrThrow() - val outputListByteArray = deserialize>(payload).getOrThrow() + payload = zSerialize(inputListByteArray).getOrThrow() + val outputListByteArray = zDeserialize>(payload).getOrThrow() assertTrue(compareByteArrayLists(inputListByteArray, outputListByteArray)) val inputMap = mapOf("key1" to "value1", "key2" to "value2", "key3" to "value3") - payload = serialize(inputMap).getOrThrow() - val outputMap = deserialize>(payload).getOrThrow() + payload = zSerialize(inputMap).getOrThrow() + val outputMap = zDeserialize>(payload).getOrThrow() assertEquals(inputMap, outputMap) val combinedInputMap = mapOf("key1" to ZBytes.from("zbytes1"), "key2" to ZBytes.from("zbytes2")) - payload = serialize(combinedInputMap).getOrThrow() - val combinedOutputMap = deserialize>(payload).getOrThrow() + payload = zSerialize(combinedInputMap).getOrThrow() + val combinedOutputMap = zDeserialize>(payload).getOrThrow() assertEquals(combinedInputMap, combinedOutputMap) /********************************************* @@ -355,7 +355,7 @@ class ZBytesTests { val fooMap = mapOf(Foo("foo1") to Foo("bar1"), Foo("foo2") to Foo("bar2")) val fooMapSerialized = ZBytes.from(serializeFooMap(fooMap)) val deserializersMap = mapOf(typeOf>() to ::deserializeFooMap) - val deserializedFooMap = deserialize>(fooMapSerialized, deserializersMap).getOrThrow() + val deserializedFooMap = zDeserialize>(fooMapSerialized, deserializersMap).getOrThrow() assertEquals(fooMap, deserializedFooMap) } @@ -482,7 +482,7 @@ class ZBytesTests { private fun deserializeIntoIntMap(serializerMap: ZBytes): Map { return deserializeIntoZBytesMap(serializerMap).map { (k, v) -> - deserialize(k).getOrThrow() to deserialize(v).getOrThrow() + zDeserialize(k).getOrThrow() to zDeserialize(v).getOrThrow() }.toMap() } From eb4403c22d811bac94c1b098f6e0cb9e529a2da5 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Mon, 30 Sep 2024 12:32:33 -0300 Subject: [PATCH 5/9] serialization: removing map for custom deserialization --- examples/src/main/kotlin/io.zenoh/ZBytes.kt | 59 ------------------- .../kotlin/io/zenoh/ext/ZDeserialize.kt | 25 +------- .../commonTest/kotlin/io/zenoh/ZBytesTest.kt | 50 ---------------- 3 files changed, 1 insertion(+), 133 deletions(-) diff --git a/examples/src/main/kotlin/io.zenoh/ZBytes.kt b/examples/src/main/kotlin/io.zenoh/ZBytes.kt index 7803a971b..7aace67a8 100644 --- a/examples/src/main/kotlin/io.zenoh/ZBytes.kt +++ b/examples/src/main/kotlin/io.zenoh/ZBytes.kt @@ -3,9 +3,6 @@ package io.zenoh import io.zenoh.bytes.* import io.zenoh.ext.zDeserialize import io.zenoh.ext.zSerialize -import java.nio.ByteBuffer -import java.nio.ByteOrder -import kotlin.reflect.typeOf fun main() { @@ -124,21 +121,6 @@ fun main() { .map { (key, value) -> MyZBytes.from(key) to MyZBytes.from(value) }.toMap() check(inputMapMyZBytes == outputMapMyZBytes) - /** - * Providing a map of deserializers. - * - * Alternatively, [zDeserialize] also accepts a deserializers parameter of type - * `Map>`. That is, a map of types that is associated - * to a function receiving a ByteArray, that returns Any. This way, you can provide a series - * of deserializer functions that extend the deserialization mechanisms we provide by default. - * - * For example, let's say we have a custom map serializer, with its own deserializer: - */ - val fooMap = mapOf(Foo("foo1") to Foo("bar1"), Foo("foo2") to Foo("bar2")) - val fooMapSerialized = ZBytes.from(serializeFooMap(fooMap)) - val deserializersMap = mapOf(typeOf>() to ::deserializeFooMap) - val deserializedFooMap = zDeserialize>(fooMapSerialized, deserializersMap).getOrThrow() - check(fooMap == deserializedFooMap) } data class MyZBytes(val content: String) : IntoZBytes { @@ -152,47 +134,6 @@ data class MyZBytes(val content: String) : IntoZBytes { } } -/** Example class for the deserialization map examples. */ -data class Foo(val content: String) - -/** Example serializer and deserializer. */ -private fun serializeFooMap(testMap: Map): ByteArray { - return testMap.map { - val key = it.key.content.toByteArray() - val keyLength = ByteBuffer.allocate(Int.SIZE_BYTES).order(ByteOrder.LITTLE_ENDIAN).putInt(key.size).array() - val value = it.value.content.toByteArray() - val valueLength = - ByteBuffer.allocate(Int.SIZE_BYTES).order(ByteOrder.LITTLE_ENDIAN).putInt(value.size).array() - keyLength + key + valueLength + value - }.reduce { acc, bytes -> acc + bytes } -} - -private fun deserializeFooMap(serializedMap: ZBytes): Map { - var idx = 0 - var sliceSize: Int - val bytes = serializedMap.toByteArray() - val decodedMap = mutableMapOf() - while (idx < bytes.size) { - sliceSize = ByteBuffer.wrap(bytes.sliceArray(IntRange(idx, idx + Int.SIZE_BYTES - 1))) - .order(ByteOrder.LITTLE_ENDIAN).int - idx += Int.SIZE_BYTES - - val key = bytes.sliceArray(IntRange(idx, idx + sliceSize - 1)) - idx += sliceSize - - sliceSize = ByteBuffer.wrap(bytes.sliceArray(IntRange(idx, idx + Int.SIZE_BYTES - 1))).order( - ByteOrder.LITTLE_ENDIAN - ).int - idx += Int.SIZE_BYTES - - val value = bytes.sliceArray(IntRange(idx, idx + sliceSize - 1)) - idx += sliceSize - - decodedMap[Foo(key.decodeToString())] = Foo(value.decodeToString()) - } - return decodedMap -} - /** Utils for this example. */ private fun compareByteArrayLists(list1: List, list2: List): Boolean { diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt index ab6738cdf..e39a49681 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/ext/ZDeserialize.kt @@ -20,34 +20,11 @@ import kotlin.reflect.typeOf * - [ByteArray] * - Lists and Maps of the above-mentioned types. * - * - * A map of types and functions for deserialization can also be provided. - * - * For instance: - * ```kotlin - * fun deserializeFoo(zbytes: ZBytes): Foo { - * return Foo(zbytes.toString()) - * } - * - * val foo = Foo("bar") - * val zbytes = serialize(foo) - * val deserialization = deserialize(zbytes, mapOf(typeOf() to ::deserializeFoo)).getOrThrow() - * ``` - * - * In case the provided type isn't associated with any of the functions provided in the [deserializers] map - * (if provided), the deserialization will carry on with the default behavior. - * * @see ZBytes * @return a [Result] with the deserialization. */ -inline fun zDeserialize(zbytes: ZBytes, - deserializers: Map> = emptyMap() -): Result { +inline fun zDeserialize(zbytes: ZBytes): Result { val type = typeOf() - val deserializer = deserializers[type] - if (deserializer != null) { - return Result.success(deserializer(zbytes) as T) - } when { typeOf>().isSupertypeOf(type) -> { val itemsClass = type.arguments.firstOrNull()?.type?.jvmErasure diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt index e211acb05..44c0b509e 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ZBytesTest.kt @@ -246,43 +246,6 @@ class ZBytesTests { assertEquals(originalMap, deserializedMap) } - @Test - fun deserializationWithMapOfDeserializationFunctionsTest() { - val stringMap = mapOf("key1" to "value1", "key2" to "value2") - val zbytesMap = stringMap.map { (k, v) -> k.into() to v.into() }.toMap() - val zbytesListOfPairs = stringMap.map { (k, v) -> k.into() to v.into() } - val intMap = mapOf(1 to 10, 2 to 20, 3 to 30) - val zbytesList = listOf(1.into(), 2.into(), 3.into()) - - val serializedBytes = serializeZBytesMap(zbytesMap) - - val customDeserializers = mapOf( - typeOf>() to ::deserializeIntoZBytesMap, - typeOf>() to ::deserializeIntoStringMap, - typeOf>() to ::deserializeIntoIntMap, - typeOf>() to ::deserializeIntoZBytesList, - typeOf>>() to ::deserializeIntoListOfPairs, - ) - - val deserializedMap = zDeserialize>(serializedBytes, customDeserializers).getOrThrow() - assertEquals(zbytesMap, deserializedMap) - - val deserializedMap2 = zDeserialize>(serializedBytes, customDeserializers).getOrThrow() - assertEquals(stringMap, deserializedMap2) - - val intMapBytes = serializeIntoIntMap(intMap) - val deserializedMap3 = zDeserialize>(intMapBytes, customDeserializers).getOrThrow() - assertEquals(intMap, deserializedMap3) - - val serializedZBytesList = serializeZBytesList(zbytesList) - val deserializedList = zDeserialize>(serializedZBytesList, customDeserializers).getOrThrow() - assertEquals(zbytesList, deserializedList) - - val serializedZBytesPairList = serializeZBytesMap(zbytesListOfPairs.toMap()) - val deserializedZBytesPairList = zDeserialize>>(serializedZBytesPairList, customDeserializers).getOrThrow() - assertEquals(zbytesListOfPairs, deserializedZBytesPairList) - } - /** * A series of tests to verify the correct functioning of the [zDeserialize] function. * @@ -344,19 +307,6 @@ class ZBytesTests { payload = zSerialize(combinedInputMap).getOrThrow() val combinedOutputMap = zDeserialize>(payload).getOrThrow() assertEquals(combinedInputMap, combinedOutputMap) - - /********************************************* - * Custom serialization and deserialization. * - *********************************************/ - - /** - * Providing a map of deserializers. - */ - val fooMap = mapOf(Foo("foo1") to Foo("bar1"), Foo("foo2") to Foo("bar2")) - val fooMapSerialized = ZBytes.from(serializeFooMap(fooMap)) - val deserializersMap = mapOf(typeOf>() to ::deserializeFooMap) - val deserializedFooMap = zDeserialize>(fooMapSerialized, deserializersMap).getOrThrow() - assertEquals(fooMap, deserializedFooMap) } /***************** From 8dc7cc2728008f6d24a11d9ac36936d99d473740 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Tue, 1 Oct 2024 06:06:01 -0300 Subject: [PATCH 6/9] serialization: pointing back to eclipse-zenoh repositories --- zenoh-jni/Cargo.lock | 217 ++++++++++++++++++++++--------------------- zenoh-jni/Cargo.toml | 4 +- 2 files changed, 111 insertions(+), 110 deletions(-) diff --git a/zenoh-jni/Cargo.lock b/zenoh-jni/Cargo.lock index ff6101533..dbbdec342 100644 --- a/zenoh-jni/Cargo.lock +++ b/zenoh-jni/Cargo.lock @@ -110,7 +110,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -122,7 +122,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -133,13 +133,13 @@ checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" @@ -231,12 +231,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "bytemuck" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" - [[package]] name = "byteorder" version = "1.5.0" @@ -245,9 +239,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cache-padded" @@ -257,9 +251,9 @@ checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21" [[package]] name = "cc" -version = "1.1.20" +version = "1.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bcde016d64c21da4be18b655631e5ab6d3107607e71a73a9f53eb48aae23fb" +checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17" dependencies = [ "shlex", ] @@ -483,7 +477,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -627,7 +621,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -706,7 +700,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -777,9 +771,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "humantime" @@ -947,9 +941,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" @@ -1184,9 +1178,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "openssl-probe" @@ -1236,7 +1233,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.4", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -1264,9 +1261,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", "thiserror", @@ -1275,9 +1272,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d" +checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" dependencies = [ "pest", "pest_generator", @@ -1285,22 +1282,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe" +checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "pest_meta" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174" +checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" dependencies = [ "once_cell", "pest", @@ -1347,7 +1344,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1376,7 +1373,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1444,6 +1441,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -1567,9 +1570,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -1587,14 +1590,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -1608,13 +1611,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -1625,9 +1628,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "ring" @@ -1746,19 +1749,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-platform-verifier" @@ -1844,7 +1846,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1879,9 +1881,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -1933,7 +1935,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1944,7 +1946,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2119,9 +2121,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -2136,7 +2138,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2156,22 +2158,22 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2263,7 +2265,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2324,7 +2326,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2415,9 +2417,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uhlc" @@ -2447,18 +2449,18 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unsafe-libyaml" @@ -2589,7 +2591,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -2611,7 +2613,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2624,9 +2626,9 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] @@ -2896,7 +2898,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "ahash", "async-trait", @@ -2945,7 +2947,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "zenoh-collections", ] @@ -2953,7 +2955,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "tracing", "uhlc", @@ -2964,12 +2966,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "json5", "num_cpus", @@ -2990,7 +2992,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "lazy_static", "tokio", @@ -3001,7 +3003,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "aes", "hmac", @@ -3014,10 +3016,9 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "bincode", - "bytemuck", "flume 0.11.0", "futures", "leb128", @@ -3032,7 +3033,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "hashbrown 0.14.5", "keyed-set", @@ -3046,7 +3047,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -3063,7 +3064,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "flume 0.11.0", @@ -3086,7 +3087,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "base64 0.22.1", @@ -3111,7 +3112,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "socket2", @@ -3128,7 +3129,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "base64 0.22.1", @@ -3155,7 +3156,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "socket2", @@ -3174,7 +3175,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "nix", @@ -3192,7 +3193,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "futures-util", @@ -3212,18 +3213,18 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "zenoh-keyexpr", ] [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "git-version", "libloading", @@ -3239,7 +3240,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "const_format", "rand", @@ -3253,7 +3254,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "anyhow", ] @@ -3261,7 +3262,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "lazy_static", "ron", @@ -3274,7 +3275,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "event-listener", "futures", @@ -3287,7 +3288,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "futures", "tokio", @@ -3300,7 +3301,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "crossbeam-utils", @@ -3333,7 +3334,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/ZettaScaleLabs/zenoh.git?branch=serialization_ext2#1b80456a43aff25ddbdfba35b5754e9bec558fa9" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#039e66ce86cc7265d8979c59acd6288718484410" dependencies = [ "async-trait", "const_format", @@ -3391,7 +3392,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] diff --git a/zenoh-jni/Cargo.toml b/zenoh-jni/Cargo.toml index 9dcdfd43c..447b67da0 100644 --- a/zenoh-jni/Cargo.toml +++ b/zenoh-jni/Cargo.toml @@ -36,8 +36,8 @@ flume = "0.10.14" uhlc = "0.8.0" json5 = "0.4.1" serde_yaml = "0.9.19" -zenoh = { version = "1.0.0-dev", git = "https://github.com/ZettaScaleLabs/zenoh.git", branch = "serialization_ext2", default-features = false } -zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/ZettaScaleLabs/zenoh.git", branch = "serialization_ext2", default-features = false } +zenoh = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } +zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } tracing = { version = "0.1" , features = ["log"] } [lib] name = "zenoh_jni" From c3c87a590b1c89ecd24470f3ee48269953ac1ebc Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Tue, 1 Oct 2024 09:45:01 -0300 Subject: [PATCH 7/9] serialization: fix ZBytes docs --- .../kotlin/io/zenoh/bytes/ZBytes.kt | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt index e186da233..3508e755f 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt @@ -53,7 +53,7 @@ import kotlin.reflect.typeOf * * using the serialize syntax: * ```kotlin * val exampleInt: Int = 256 - * val zbytes: ZBytes = serialize(exampleInt).getOrThrow() + * val zbytes: ZBytes = zSerialize(exampleInt).getOrThrow() * ``` * This approach works as well for the other mentioned types. * @@ -68,7 +68,7 @@ import kotlin.reflect.typeOf * The serialize syntax must be used: * ```kotlin * val myList = listOf(1, 2, 5, 8, 13, 21) - * val zbytes = serialize>(myList).getOrThrow() + * val zbytes = zSerialize>(myList).getOrThrow() * ``` * * ## Maps @@ -81,7 +81,7 @@ import kotlin.reflect.typeOf * * ```kotlin * val myMap: Map = mapOf("foo" to 1, "bar" to 2) - * val zbytes = serialize>(myMap).getOrThrow() + * val zbytes = zSerialize>(myMap).getOrThrow() * ``` * * # Deserialization @@ -114,7 +114,7 @@ import kotlin.reflect.typeOf * ```kotlin * val exampleInt: Int = 256 * val zbytes: ZBytes = exampleInt.into() - * val deserializedInt = deserialize(zbytes).getOrThrow() + * val deserializedInt = zDeserializeInt>(zbytes).getOrThrow() * ``` * * ## Lists @@ -128,7 +128,7 @@ import kotlin.reflect.typeOf * ```kotlin * val inputList = listOf("sample1", "sample2", "sample3") * payload = serialize(inputList).getOrThrow() - * val outputList = deserialize>(payload).getOrThrow() + * val outputList = zDeserializeList>(payload).getOrThrow() * ``` * * ## Maps @@ -141,7 +141,7 @@ import kotlin.reflect.typeOf * ```kotlin * val inputMap = mapOf("key1" to "value1", "key2" to "value2", "key3" to "value3") * payload = serialize(inputMap).getOrThrow() - * val outputMap = deserialize>(payload).getOrThrow() + * val outputMap = zDeserializeMap>(payload).getOrThrow() * check(inputMap == outputMap) * ``` * @@ -163,14 +163,14 @@ import kotlin.reflect.typeOf * This way, we can do: * ```kotlin * val foo = Foo("bar") - * val serialization = serialize(foo).getOrThrow() + * val serialization = zSerialize(foo).getOrThrow() * ``` * * Implementing the [IntoZBytes] interface on a class enables the possibility of serializing lists and maps * of that type, for instance: * ```kotlin * val list = listOf(Foo("bar"), Foo("buz"), Foo("fizz")) - * val zbytes = serialize>(list) + * val zbytes = zSerialize>(list) * ``` * * ## Deserialization @@ -189,36 +189,17 @@ import kotlin.reflect.typeOf * * // List of Foo. * val inputListFoo = inputList.map { value -> Foo(value) } - * payload = serialize>(inputListFoo).getOrThrow() - * val outputListFoo = deserialize>(payload).getOrThrow().map { zbytes -> Foo.from(zbytes) } + * payload = zSerialize>(inputListFoo).getOrThrow() + * val outputListFoo = zDeserializeList>(payload).getOrThrow().map { zbytes -> Foo.from(zbytes) } * check(inputListFoo == outputListFoo) * * // Map of Foo. * val inputMapFoo = inputMap.map { (k, v) -> Foo(k) to Foo(v) }.toMap() - * payload = serialize>(inputMapFoo).getOrThrow() - * val outputMapFoo = deserialize>(payload).getOrThrow() + * payload = zSerialize>(inputMapFoo).getOrThrow() + * val outputMapFoo = zDeserializeMap>(payload).getOrThrow() * .map { (key, value) -> Foo.from(key) to Foo.from(value) }.toMap() * check(inputMapFoo == outputMapFoo) * ``` - * - * ### Deserialization functions: - * - * The [deserialize] function admits an argument which by default is an emptyMap, consisting - * of a `Map>` map. This allows to specify types in a map, associating - * functions for deserialization for each of the types in the map. - * - * For instance, let's stick to the previous implementation of our example Foo class. - * We could provide directly the deserialization function as follows: - * - * ```kotlin - * fun deserializeFoo(zbytes: ZBytes): Foo { - * return Foo(zbytes.toString()) - * } - * - * val foo = Foo("bar") - * val zbytes = serialize(foo) - * val deserialization = deserialize(zbytes, mapOf(typeOf() to ::deserializeFoo)).getOrThrow() - * ``` */ class ZBytes internal constructor(internal val bytes: ByteArray) : IntoZBytes { From f9337400257ab8710491e1571220578b85319a70 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Tue, 1 Oct 2024 09:56:39 -0300 Subject: [PATCH 8/9] Serialization: update Cargo.toml features --- zenoh-jni/Cargo.lock | 56 ++++++++++++++++++++++---------------------- zenoh-jni/Cargo.toml | 6 ++--- zenoh-jni/src/lib.rs | 1 + 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/zenoh-jni/Cargo.lock b/zenoh-jni/Cargo.lock index 7a9425d3e..6e08a5194 100644 --- a/zenoh-jni/Cargo.lock +++ b/zenoh-jni/Cargo.lock @@ -251,9 +251,9 @@ checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21" [[package]] name = "cc" -version = "1.1.23" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "shlex", ] @@ -2898,7 +2898,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "ahash", "async-trait", @@ -2947,7 +2947,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "zenoh-collections", ] @@ -2955,7 +2955,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "tracing", "uhlc", @@ -2966,12 +2966,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "json5", "num_cpus", @@ -2992,7 +2992,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "lazy_static", "tokio", @@ -3003,7 +3003,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "aes", "hmac", @@ -3016,7 +3016,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "bincode", "flume 0.11.0", @@ -3033,7 +3033,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "hashbrown 0.14.5", "keyed-set", @@ -3047,7 +3047,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -3064,7 +3064,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "flume 0.11.0", @@ -3087,7 +3087,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "base64 0.22.1", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "socket2", @@ -3129,7 +3129,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "base64 0.22.1", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "socket2", @@ -3175,7 +3175,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "nix", @@ -3193,7 +3193,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "futures-util", @@ -3213,7 +3213,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "proc-macro2", "quote", @@ -3224,7 +3224,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "git-version", "libloading", @@ -3240,7 +3240,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "const_format", "rand", @@ -3254,7 +3254,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "anyhow", ] @@ -3262,7 +3262,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "lazy_static", "ron", @@ -3275,7 +3275,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "event-listener", "futures", @@ -3288,7 +3288,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "futures", "tokio", @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "crossbeam-utils", @@ -3334,7 +3334,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#1b59c6aad53344432d50a432e03901a903b1a79a" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" dependencies = [ "async-trait", "const_format", diff --git a/zenoh-jni/Cargo.toml b/zenoh-jni/Cargo.toml index 447b67da0..a38606df3 100644 --- a/zenoh-jni/Cargo.toml +++ b/zenoh-jni/Cargo.toml @@ -24,7 +24,7 @@ description = "Zenoh: Zero Overhead Pub/sub, Store/Query and Compute." name = "zenoh_jni" [features] -default = ["zenoh/default", "zenoh-ext/default"] +default = ["zenoh/default", "zenoh-ext"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -36,8 +36,8 @@ flume = "0.10.14" uhlc = "0.8.0" json5 = "0.4.1" serde_yaml = "0.9.19" -zenoh = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } -zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } +zenoh = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["unstable", "internal"], default-features = false } +zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, optional = true } tracing = { version = "0.1" , features = ["log"] } [lib] name = "zenoh_jni" diff --git a/zenoh-jni/src/lib.rs b/zenoh-jni/src/lib.rs index 0b815ad66..6661ee551 100644 --- a/zenoh-jni/src/lib.rs +++ b/zenoh-jni/src/lib.rs @@ -23,6 +23,7 @@ mod scouting; mod session; mod subscriber; mod utils; +#[cfg(feature = "zenoh-ext")] mod zbytes; mod zenoh_id; From 56c48634a75bd4851cbaa80990bdc368c694ff8d Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Tue, 1 Oct 2024 11:44:36 -0300 Subject: [PATCH 9/9] Cargo update --- zenoh-jni/Cargo.lock | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/zenoh-jni/Cargo.lock b/zenoh-jni/Cargo.lock index 6e08a5194..96b19d02e 100644 --- a/zenoh-jni/Cargo.lock +++ b/zenoh-jni/Cargo.lock @@ -2898,7 +2898,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "ahash", "async-trait", @@ -2947,7 +2947,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "zenoh-collections", ] @@ -2955,7 +2955,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "tracing", "uhlc", @@ -2966,12 +2966,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "json5", "num_cpus", @@ -2992,7 +2992,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "lazy_static", "tokio", @@ -3003,7 +3003,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "aes", "hmac", @@ -3016,7 +3016,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "bincode", "flume 0.11.0", @@ -3033,7 +3033,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "hashbrown 0.14.5", "keyed-set", @@ -3047,7 +3047,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -3064,7 +3064,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "flume 0.11.0", @@ -3087,7 +3087,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "base64 0.22.1", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "socket2", @@ -3129,7 +3129,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "base64 0.22.1", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "socket2", @@ -3175,7 +3175,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "nix", @@ -3193,7 +3193,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "futures-util", @@ -3213,7 +3213,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "proc-macro2", "quote", @@ -3224,7 +3224,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "git-version", "libloading", @@ -3240,7 +3240,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "const_format", "rand", @@ -3254,7 +3254,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "anyhow", ] @@ -3262,7 +3262,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "lazy_static", "ron", @@ -3275,7 +3275,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "event-listener", "futures", @@ -3288,7 +3288,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "futures", "tokio", @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "crossbeam-utils", @@ -3334,7 +3334,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#febd589126a4e16d120d04d36e4b50430f569881" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#89efcce08fa7d3a50f520311b23308f175c8bd74" dependencies = [ "async-trait", "const_format",