rustdds/
serialization.rs

1mod cdr_adapters;
2
3pub(crate) mod pl_cdr_adapters;
4pub(crate) mod speedy_pl_cdr_helpers;
5
6mod representation_identifier;
7
8// Most of the CDR encoding/decoding comes from this external crate
9pub use cdr_encoding::{
10  from_bytes, to_vec, to_writer, CdrDeserializer, CdrSerializer, Error, Result,
11};
12// Export some parts of inner modules
13pub use cdr_adapters::{
14  deserialize_from_cdr_with_decoder_and_rep_id, deserialize_from_cdr_with_rep_id,
15  to_writer_with_rep_id, CDRDeserializerAdapter, CDRSerializerAdapter, CdrDeserializeSeedDecoder,
16};
17pub use representation_identifier::RepresentationIdentifier;
18
19// Compute how much padding bytes are needed to
20// get the next multiple of 4
21pub fn padding_needed_for_alignment_4(unaligned_length: usize) -> usize {
22  if unaligned_length % 4 != 0 {
23    4 - (unaligned_length % 4)
24  } else {
25    0
26  }
27}
28
29pub fn round_up_to_4(unaligned_length: usize) -> usize {
30  unaligned_length + padding_needed_for_alignment_4(unaligned_length)
31}