Skip to content

Commit 8d7d833

Browse files
committed
resolve comments: update rust comments
1 parent c8628de commit 8d7d833

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

iceoryx2/src/service/static_config/message_type_details.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,24 @@ use serde::{Deserialize, Serialize};
2020
#[derive(Default, Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
2121
pub enum TypeVariant {
2222
#[default]
23-
/// A fixed size type which is determined during compile.
24-
/// A structure holds some pointer fields should be clarified as Dynamic.
23+
/// A type notated by [`#[repr(C)]`](https://doc.rust-lang.org/reference/type-layout.html#reprc).
24+
/// with a constant size known at compile time is recognized as FixedSize.
25+
/// The FixedSize type should satisfy the [`Sized`].
26+
/// For example, all primitive types are FixedSize. The self-contained structs(without pointer members
27+
/// or heap-usages) are FixedSize.
2528
FixedSize,
26-
/// A dynamic sized type like a slice or it contains some pointer fields.
29+
30+
/// A dynamic sized type strictly refers to the slice of an iceoryx2 compatible types.
31+
/// The struct with pointer members or with heap usage MUSTN't be recognized as Dynamic type.
32+
/// Indeed, they're the in-compatible iceoryx2 types.
33+
///
34+
/// The underlying reason is the shared memory which we use to store the payload data.
35+
/// If the payload type would use the heap then the type would use
36+
/// process local memory that is not available to another process.
37+
///
38+
/// The pointer requirement comes again from shared memory.
39+
/// It has a different pointer address offset in every process rendering any absolute pointer
40+
/// useless and dereferencing it would end up in a segfault.
2741
Dynamic,
2842
}
2943

@@ -37,6 +51,7 @@ pub struct TypeDetail {
3751
/// The size of the underlying type calculated by [`core::mem::size_of`].
3852
pub size: usize,
3953
/// The ABI-required minimum alignment of the underlying type calculated by [`core::mem::align_of`].
54+
/// It may be set by users with a larger alignment, e.g the memory provided by allocator used by SIMD.
4055
pub alignment: usize,
4156
}
4257

@@ -79,7 +94,7 @@ impl MessageTypeDetails {
7994
payload_start as *const u8
8095
}
8196

82-
/// returns pointer of user_header which is the field follows the header field in a structure.
97+
/// returns the pointer to the user header
8398
pub(crate) fn user_header_ptr_from_header(&self, header: *const u8) -> *const u8 {
8499
let header = header as usize;
85100
let user_header_start = align(header + self.header.size, self.user_header.alignment);
@@ -136,7 +151,7 @@ mod tests {
136151
_b: bool,
137152
_c: i64,
138153
}
139-
154+
140155
let sut = MessageTypeDetails::from::<i32, i64, MyPayload>(TypeVariant::FixedSize);
141156
let expected = MessageTypeDetails{
142157
header: TypeDetail{

0 commit comments

Comments
 (0)