Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: move serialization into zenoh-ext #1473

Merged
merged 33 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3938495
feat!: move serialization into zenoh-ext
wyfo Sep 25, 2024
b589b78
refactor: rename write_xxx/read_xxx to (de)serialize_xxx
wyfo Sep 25, 2024
aecbb83
fix: lints
wyfo Sep 25, 2024
3f91c7a
fix: fix `ZBytes::as_shm`
wyfo Sep 25, 2024
df18470
fix: make protoc non-mandatory to execute z_bytes example
wyfo Sep 25, 2024
9c70e62
fix: lint
wyfo Sep 25, 2024
6f233e0
fix: lint
wyfo Sep 25, 2024
a0169e2
fix: lint
wyfo Sep 25, 2024
757e262
fix: add Serialize implementation for ZBytes
wyfo Sep 25, 2024
4d238f9
fix: lints
wyfo Sep 25, 2024
254698d
refactor: replace extension traits by dedicated types
wyfo Sep 25, 2024
aec6cf3
fix: lints
wyfo Sep 26, 2024
a3d5177
fix: add `?Sized` bound to `z_serialize`
wyfo Sep 26, 2024
1f11f57
fix: add VarInt implementation
wyfo Sep 26, 2024
ddf3ee5
feat!: ZBytesWriter/ZSerializer have no more lifetime
wyfo Sep 27, 2024
1b80456
feat: use bytemuck for `VarInt` slice conversion
wyfo Sep 27, 2024
8362a22
feat: remove bytemuck depedency
wyfo Sep 27, 2024
86143b5
fix: remove litigious `From` implementation
wyfo Sep 29, 2024
134744d
fix: fix tests
wyfo Sep 29, 2024
fcdbce9
fix: fix tests
wyfo Sep 29, 2024
3643859
docs: add varint example
wyfo Sep 30, 2024
be62890
fix: typo
wyfo Sep 30, 2024
cf07598
fix: fix serialization test
wyfo Sep 30, 2024
2b5dd1c
fix: outdated doc
wyfo Sep 30, 2024
a6f8828
feat: add `ZDeserializer::deserialize_n`
wyfo Sep 30, 2024
607d801
fix: typo
wyfo Sep 30, 2024
8e3225f
fix: remove useless dependency
wyfo Sep 30, 2024
76d0434
fix: fix test
wyfo Sep 30, 2024
6fefeaa
serialization for zenoh types Encoding and Timestamp
milyin Sep 30, 2024
e78cc9f
fix: test
wyfo Sep 30, 2024
2acefcd
feat: implement serialization for array as variable-size collection
wyfo Sep 30, 2024
b4f8991
docs: add array example in z_bytes
wyfo Sep 30, 2024
509c822
code formatting
milyin Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 73 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ tokio-rustls = { version = "0.26.0", default-features = false }
thread-priority = "1.1.0"
typenum = "1.17.0"
uhlc = { version = "0.8.0", default-features = false } # Default features are disabled due to usage in no_std crates
unwrap-infallible = "0.1.5"
unzip-n = "0.1.2"
url = "2.5.2"
urlencoding = "2.1.3"
Expand Down
4 changes: 2 additions & 2 deletions ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ async fn main() {
sample.key_expr().as_str(),
sample
.payload()
.deserialize::<String>()
.unwrap_or_else(|e| format!("{}", e))
.try_to_string()
.unwrap_or_else(|e| e.to_string().into())
);
})
.await
Expand Down
8 changes: 4 additions & 4 deletions ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ async fn main() {
sample.key_expr().as_str(),
sample
.payload()
.deserialize::<String>()
.unwrap_or_else(|e| format!("{}", e))
.try_to_string()
.unwrap_or_else(|e| e.to_string().into())
),
Err(err) => println!(
">> Received (ERROR: '{}')",
err.payload()
.deserialize::<String>()
.unwrap_or_else(|e| format!("{}", e))
.try_to_string()
.unwrap_or_else(|e| e.to_string().into())
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-buffers/src/zbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl<'a> io::Seek for ZBufReader<'a> {
.fold(0, |acc, s| acc + s.len())
+ self.cursor.byte;
let current_pos = i64::try_from(current_pos)
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)))?;
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;

let offset = match pos {
std::io::SeekFrom::Start(s) => i64::try_from(s).unwrap_or(i64::MAX) - current_pos,
Expand Down
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ prost = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "time", "io-std"] }
unwrap-infallible = { workspace = true }
zenoh = { workspace = true, default-features = true }
zenoh-ext = { workspace = true }

[dev-dependencies]
rand = { workspace = true, features = ["default"] }

[build-dependencies]
rustc_version = { workspace = true }
prost-build = "0.13"
which = "6"

[[example]]
name = "z_scout"
Expand Down
16 changes: 16 additions & 0 deletions examples/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::{env, fs::File, io::Write, path::Path};

use which::which;

fn main() -> std::io::Result<()> {
// If protoc is not installed, we cheat because building protoc from source
// with protobuf-src is way too long
if which("protoc").is_err() {
const PROTO: &str = r#"#[derive(Clone, PartialEq, ::prost::Message)] pub struct Entity { #[prost(uint32, tag = "1")] pub id: u32, #[prost(string, tag = "2")] pub name: ::prost::alloc::string::String,}"#;
let out_path = Path::new(&env::var("OUT_DIR").unwrap()).join("example.rs");
File::create(out_path)?.write_all(PROTO.as_bytes())?;
return Ok(());
}
prost_build::compile_protos(&["examples/example.proto"], &["examples/"])?;
Ok(())
}
Loading
Loading