Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "Serde implementation of OMG Common Data Representation (CDR) enco
readme = "README.md"
keywords = ["network","protocol","dds","rtps"]
license = "Apache-2.0"
homepage = "https://atostek.com/en/products/rustdds/"
homepage = "https://atostek.com/en/products/rustdds/"
repository = "https://github.com/jhelovuo/cdr-encoding"

[workspace]
Expand All @@ -19,7 +19,7 @@ members = [
]


# Although cdr-encoding, cdr-encoding-size, and cdr-encoding-size-derive
# Although cdr-encoding, cdr-encoding-size, and cdr-encoding-size-derive
# are relaed semantically,
# the main crate cdr-encoding does not technically depend on the two others.
#
Expand Down
10 changes: 9 additions & 1 deletion src/cdr_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,15 @@ where
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
// Align to 4 bytes
self.calculate_padding_count_from_written_bytes_and_remove(4)?;
// Length prefix
let len = self.next_bytes(4)?.read_u32::<BO>().unwrap() as usize;
// Read the entire buffer at once
let buf = self.next_bytes(len)?.to_vec();

visitor.visit_byte_buf(buf)

}

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value>
Expand Down
3 changes: 3 additions & 0 deletions src/cdr_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ where
}

fn serialize_bytes(self, v: &[u8]) -> Result<()> {
// Write length prefix
self.serialize_u32(v.len() as u32)?;
// Write raw bytes
self.writer.write_all(v)?;
Ok(())
}
Expand Down