diff --git a/Cargo.lock b/Cargo.lock index e5a0f3e..8496363 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2741,7 +2741,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "ahash", "async-trait", @@ -2790,7 +2790,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "zenoh-collections", ] @@ -2798,7 +2798,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "tracing", "uhlc", @@ -2809,12 +2809,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" [[package]] name = "zenoh-config" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "json5", "num_cpus", @@ -2835,7 +2835,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "lazy_static", "tokio", @@ -2846,7 +2846,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "aes", "hmac", @@ -2859,7 +2859,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "bincode", "flume", @@ -2876,7 +2876,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "hashbrown", "keyed-set", @@ -2890,7 +2890,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "zenoh-config", "zenoh-link-commons", @@ -2907,7 +2907,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "flume", @@ -2930,7 +2930,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "base64 0.22.1", @@ -2955,7 +2955,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "socket2", @@ -2972,7 +2972,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "base64 0.22.1", @@ -2999,7 +2999,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "socket2", @@ -3018,7 +3018,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "nix", @@ -3036,7 +3036,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "futures-util", @@ -3056,7 +3056,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "proc-macro2", "quote", @@ -3067,7 +3067,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "git-version", "libloading", @@ -3083,7 +3083,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "const_format", "rand", @@ -3110,7 +3110,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "anyhow", ] @@ -3118,7 +3118,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "lazy_static", "ron", @@ -3131,7 +3131,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "event-listener", "futures", @@ -3144,7 +3144,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "futures", "tokio", @@ -3157,7 +3157,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "crossbeam-utils", @@ -3190,7 +3190,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.0.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#d8762bffc2f2d4d8af9959f1cc109adce819fb1b" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#8cf493cf42d396294510e1e0619a7f437683ed20" dependencies = [ "async-trait", "const_format", diff --git a/Cargo.toml b/Cargo.toml index 069f633..5669243 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,4 +51,4 @@ pyo3 = { version = "0.21.2", features = [ ] } validated_struct = "2.1.0" 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 } +zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["internal"], optional = true } diff --git a/examples/z_bytes.py b/examples/z_bytes.py index f8b1dce..ca7e4f1 100644 --- a/examples/z_bytes.py +++ b/examples/z_bytes.py @@ -63,19 +63,12 @@ def main(): if True: # Numeric: UInt8, UInt16, Uint32, UInt64, UInt128, Int8, Int16, Int32, Int64, - # Int128, Float32, Float64, float (handled as Float64) + # Int128, int (handled as int32), Float32, Float64, float (handled as Float64) input = UInt32(1234) payload = z_serialize(input) output = z_deserialize(UInt32, payload) assert input == output - # Varint LEB128: VarInt, VarUInt, int (handled as VarInt) - input = 42 - payload = z_serialize(input) - assert len(payload.to_bytes()) == 1 - output = z_deserialize(int, payload) - assert input == output - # list input = [0.0, 1.5, 42.0] # all items must have the same type payload = z_serialize(input) diff --git a/src/ext.rs b/src/ext.rs index 44f91a8..ef927c2 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -36,8 +36,6 @@ enum SupportedType { Float, Float32, Float64, - VarInt, - VarUInt, Bool, List, Tuple, @@ -75,8 +73,6 @@ impl SupportedType { add_type::(py, &dict, SupportedType::Float); add_wrapper_type("Float32", SupportedType::Float32); add_wrapper_type("Float64", SupportedType::Float64); - add_wrapper_type("VarInt", SupportedType::VarInt); - add_wrapper_type("VarUInt", SupportedType::VarUInt); add_type::(py, &dict, SupportedType::Bool); add_type::(py, &dict, SupportedType::List); add_type::(py, &dict, SupportedType::Tuple); @@ -106,8 +102,6 @@ impl SupportedType { n if n == Self::Float as u8 => Self::Float, n if n == Self::Float32 as u8 => Self::Float32, n if n == Self::Float64 as u8 => Self::Float64, - n if n == Self::VarInt as u8 => Self::VarInt, - n if n == Self::VarUInt as u8 => Self::VarUInt, n if n == Self::Bool as u8 => Self::Bool, n if n == Self::List as u8 => Self::List, n if n == Self::Tuple as u8 => Self::Tuple, @@ -173,7 +167,7 @@ fn serialize_impl( SupportedType::Str => serializer.serialize(&obj.downcast::()?.to_cow()?), SupportedType::Int8 => serializer.serialize(i8::extract_bound(obj)?), SupportedType::Int16 => serializer.serialize(i16::extract_bound(obj)?), - SupportedType::Int32 => serializer.serialize(i32::extract_bound(obj)?), + SupportedType::Int | SupportedType::Int32 => serializer.serialize(i32::extract_bound(obj)?), SupportedType::Int64 => serializer.serialize(i64::extract_bound(obj)?), SupportedType::Int128 => serializer.serialize(i128::extract_bound(obj)?), SupportedType::UInt8 => serializer.serialize(u8::extract_bound(obj)?), @@ -185,10 +179,6 @@ fn serialize_impl( serializer.serialize(f64::extract_bound(obj)?) } SupportedType::Float32 => serializer.serialize(f64::extract_bound(obj)? as f32), - SupportedType::VarInt | SupportedType::Int => { - serializer.serialize(VarInt(i64::extract_bound(obj)?)) - } - SupportedType::VarUInt => serializer.serialize(VarInt(u64::extract_bound(obj)?)), SupportedType::Bool => serializer.serialize(bool::extract_bound(obj)?), SupportedType::List => serialize_iter( serializer, @@ -327,7 +317,7 @@ fn deserialize_impl( PyBytes::new_bound(py, &deserializer.deserialize::>()?).into_py(py) } SupportedType::Str => deserializer.deserialize::()?.into_py(py), - SupportedType::Int => deserializer.deserialize::>()?.0.into_py(py), + SupportedType::Int => deserializer.deserialize::()?.into_py(py), SupportedType::Int8 => deserialize_wrapper!(i8, Int8), SupportedType::Int16 => deserialize_wrapper!(i16, Int16), SupportedType::Int32 => deserialize_wrapper!(i32, Int32), @@ -341,12 +331,6 @@ fn deserialize_impl( SupportedType::Float => deserializer.deserialize::()?.into_py(py), SupportedType::Float32 => deserialize_wrapper!(f32, Float32), SupportedType::Float64 => deserialize_wrapper!(f64, Float64), - SupportedType::VarInt => import!(py, "zenoh.ext", VarInt) - .call1((deserializer.deserialize::>()?.0,))? - .into_py(py), - SupportedType::VarUInt => import!(py, "zenoh.ext", VarUInt) - .call1((deserializer.deserialize::>()?.0,))? - .into_py(py), SupportedType::Bool => deserializer.deserialize::()?.into_py(py), tp @ (SupportedType::List | SupportedType::Set | SupportedType::FrozenSet) => { deserialize_collection(deserializer, py, tp, unwrap_args()?)? diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 6eea5b4..7854d6a 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -30,8 +30,6 @@ UInt32, UInt64, UInt128, - VarInt, - VarUInt, z_deserialize, z_serialize, ) @@ -41,12 +39,12 @@ (bytes, b"foo"), (bytearray, bytearray(b"foo")), (str, "foo"), - (int, -42), - (int, 42), - *((tp, tp(-42)) for tp in (Int8, Int16, Int32, Int64, Int128)), + *( + (tp, tp(i)) + for i in (-42, 42) + for tp in (int, Int8, Int16, Int32, Int64, Int128) + ), *((tp, tp(42)) for tp in (UInt8, UInt16, UInt32, UInt64, UInt128)), - (VarUInt, VarUInt(42)), - (VarInt, VarInt(-42)), (float, 0.5), (Float64, Float64(0.5)), (Float32, Float32(0.5)), diff --git a/zenoh/ext.py b/zenoh/ext.py index a769256..028ae25 100644 --- a/zenoh/ext.py +++ b/zenoh/ext.py @@ -112,11 +112,3 @@ class Float32(float): class Float64(float): """float subclass enabling to (de)serialize 64bit floating point numbers.""" - - -class VarUInt(int): - """int subclass enabling to (de)serialize unsigned varint.""" - - -class VarInt(int): - """int subclass enabling to (de)serialize signed varint.""" diff --git a/zenoh/ext.pyi b/zenoh/ext.pyi index 296c00a..a497f78 100644 --- a/zenoh/ext.pyi +++ b/zenoh/ext.pyi @@ -40,12 +40,6 @@ class Float32(float): class Float64(float): """float subclass enabling to (de)serialize 64bit floating point numbers.""" -class VarUInt(int): - """int subclass enabling to (de)serialize unsigned varint.""" - -class VarInt(int): - """int subclass enabling to (de)serialize signed varint.""" - class ZDeserializeError(Exception): pass