|
10 | 10 | //
|
11 | 11 | // SPDX-License-Identifier: Apache-2.0 OR MIT
|
12 | 12 |
|
13 |
| -//! Contains standard container which are compatible with an inter-process shared memory usage. |
| 13 | +//! # Iceoryx2 Building Blocks (BB) Container |
| 14 | +//! |
| 15 | +//! This is a support library for iceoryx2 which comes with containers that are |
| 16 | +//! compatible with shared memory and can be used to construct custom payload types for |
| 17 | +//! inter-process communication. |
| 18 | +//! |
| 19 | +//! Most containers come in 3 variations: |
| 20 | +//! 1. `FixedSize***`, compile-time fixed size version. The capacity must be known at compile |
| 21 | +//! time. |
| 22 | +//! 2. `Relocatable***`, run-time fixed size version that is shared memory compatible. The |
| 23 | +//! capacity must be known when the object is created. **This object is not movable!** |
| 24 | +//! 3. `***`, run-time fixed size version that is **not** shared memory compatible but can be |
| 25 | +//! moved. |
| 26 | +//! |
| 27 | +//! # Example |
| 28 | +//! |
| 29 | +//! ## 1. Compile-Time FixedSize Containers |
| 30 | +//! |
| 31 | +//! We create a struct consisting of compile-time fixed size containers that can be used for |
| 32 | +//! zero copy inter-process communication. |
| 33 | +//! |
| 34 | +//! ``` |
| 35 | +//! use iceoryx2_bb_container::byte_string::*; |
| 36 | +//! use iceoryx2_bb_container::vec::*; |
| 37 | +//! |
| 38 | +//! const TEXT_CAPACITY: usize = 123; |
| 39 | +//! const DATA_CAPACITY: usize = 456; |
| 40 | +//! |
| 41 | +//! #[repr(C)] |
| 42 | +//! struct MyMessageType { |
| 43 | +//! some_text: FixedSizeByteString<TEXT_CAPACITY>, |
| 44 | +//! some_data: FixedSizeVec<u64, DATA_CAPACITY>, |
| 45 | +//! } |
| 46 | +//! |
| 47 | +//! # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 48 | +//! let my_message = MyMessageType { |
| 49 | +//! some_text: FixedSizeByteString::from_bytes(b"Hello World")?, |
| 50 | +//! some_data: FixedSizeVec::new(), |
| 51 | +//! }; |
| 52 | +//! # Ok(()) |
| 53 | +//! # } |
| 54 | +//! ``` |
| 55 | +//! |
| 56 | +//! ## 2. Shared Memory Compatible Run-Time FixedSize Containers |
| 57 | +//! |
| 58 | +//! Despite that the containers are already implemented, iceoryx2 itself does not yet support |
| 59 | +//! run-time fixed size types. It is planned and will come. |
| 60 | +//! |
| 61 | +//! ## 3. Run-Time FixedSize Containers |
| 62 | +//! |
| 63 | +//! We create a struct consisting of run-time fixed size containers. This can be interesting when |
| 64 | +//! it shall be used in a safety-critical environment where everything must be pre-allocated to |
| 65 | +//! ensure that required memory is always available. |
| 66 | +//! |
| 67 | +//! ``` |
| 68 | +//! use iceoryx2_bb_container::queue::*; |
| 69 | +//! |
| 70 | +//! const QUEUE_CAPACITY: usize = 123; |
| 71 | +//! |
| 72 | +//! #[repr(C)] |
| 73 | +//! struct MyType { |
| 74 | +//! some_queue: Queue<u64>, |
| 75 | +//! } |
| 76 | +//! |
| 77 | +//! # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 78 | +//! let my_thing = MyType { |
| 79 | +//! some_queue: Queue::new(QUEUE_CAPACITY), |
| 80 | +//! }; |
| 81 | +//! # Ok(()) |
| 82 | +//! # } |
| 83 | +//! ``` |
14 | 84 |
|
| 85 | +/// A byte string similar to [`std::string::String`] but it does not support UTF-8 |
15 | 86 | pub mod byte_string;
|
| 87 | +/// A queue similar to [`std::collections::VecDeque`] |
16 | 88 | pub mod queue;
|
| 89 | +/// Extends the [ByteString](crate::byte_string) so that custom string types with a semantic |
| 90 | +/// ruleset on their content can be realized. |
17 | 91 | #[macro_use]
|
18 | 92 | pub mod semantic_string;
|
| 93 | +/// A vector similar to [`std::vec::Vec`] |
19 | 94 | pub mod vec;
|
0 commit comments