Skip to content

Commit

Permalink
Additional SequenceNumber members for RPC/ROS2 to avoid duplicate imp…
Browse files Browse the repository at this point in the history
…lementation in ros2-client.
  • Loading branch information
jhelovuo committed Oct 11, 2023
1 parent a65f5bf commit 96d2895
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/structure/sequence_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,23 @@ impl SequenceNumber {
}

pub const fn plus_1(&self) -> Self {
SequenceNumber(self.0 + 1)
SequenceNumber( self.0 + 1 )
}

pub fn next(&self) -> SequenceNumber {
self.plus_1()
}

pub fn from_high_low(high: i32, low: u32) -> Self {
Self( ((high as i64) << 32) + (low as i64) )
}

pub fn high(&self) -> i32 {
(self.0 >> 32) as i32
}

pub fn low(&self) -> u32 {
(self.0 & 0xFFFF_FFFF) as u32
}
}

Expand Down Expand Up @@ -79,6 +95,7 @@ impl From<SequenceNumber> for i64 {
}
}


// ---------------------------------------

#[derive(Clone, Copy, Debug)]
Expand Down Expand Up @@ -403,7 +420,7 @@ where
end
};
// sanity ok. Now do the actual work.
let num_bits = i64::from(end - base + N::from(1));
let num_bits = i64::from( end - base + N::from(1) );
let mut sns = Self::new(base, num_bits as u32);
for s in set.iter().filter(|s| base <= **s && **s <= end) {
sns.insert(*s);
Expand Down

0 comments on commit 96d2895

Please sign in to comment.