Skip to content

Commit

Permalink
Fix handling Vec of varint types (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 authored May 2, 2023
1 parent 0397aa5 commit ff590dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ntex-grpc/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [0.3.6] - 2023-05-02

* Fix handling Vec of varint types

## [0.3.5] - 2023-04-06

* Fix panic on error after stream eof
Expand Down
2 changes: 1 addition & 1 deletion ntex-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-grpc"
version = "0.3.5"
version = "0.3.6"
license = "MIT"
authors = ["Nikolay Kim <[email protected]>"]
description = "GRPC Client/Server framework"
Expand Down
15 changes: 12 additions & 3 deletions ntex-grpc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,18 @@ impl<T: NativeType> NativeType for Vec<T> {
wtype: WireType,
src: &mut Bytes,
) -> Result<(), DecodeError> {
let mut value: T = Default::default();
value.deserialize(tag, wtype, src)?;
self.push(value);
if T::TYPE == WireType::Varint {
let len = encoding::decode_varint(src)? as usize;
for _ in 0..len {
let mut value: T = Default::default();
value.merge(src)?;
self.push(value);
}
} else {
let mut value: T = Default::default();
value.deserialize(tag, wtype, src)?;
self.push(value);
}
Ok(())
}

Expand Down

0 comments on commit ff590dd

Please sign in to comment.