Skip to content

Commit

Permalink
Merge pull request #367 from elfenpiff/iox2-264-config-api
Browse files Browse the repository at this point in the history
[#264] config api
  • Loading branch information
elfenpiff authored Sep 11, 2024
2 parents 5eb3eac + d8a963a commit b4b8d9c
Show file tree
Hide file tree
Showing 40 changed files with 2,808 additions and 180 deletions.
4 changes: 2 additions & 2 deletions iceoryx2-bb/container/src/semantic_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ pub trait SemanticString<const CAPACITY: usize>:
/// * The contents must have a length that is less or equal CAPACITY
/// * The contents must not contain invalid UTF-8 characters
///
unsafe fn from_c_str(ptr: *mut std::ffi::c_char) -> Result<Self, SemanticStringError> {
unsafe fn from_c_str(ptr: *const std::ffi::c_char) -> Result<Self, SemanticStringError> {
Self::new(std::slice::from_raw_parts(
ptr as *const u8,
ptr.cast(),
strnlen(ptr, CAPACITY + 1),
))
}
Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/communication_channel/message_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
16 changes: 8 additions & 8 deletions iceoryx2-cal/src/communication_channel/posix_shared_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,28 @@ impl Default for Configuration {
impl From<Configuration> for dynamic_storage::posix_shared_memory::Configuration<Management> {
fn from(value: Configuration) -> Self {
Self::default()
.suffix(value.suffix)
.path_hint(value.path_hint)
.suffix(&value.suffix)
.path_hint(&value.path_hint)
}
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/communication_channel/process_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/communication_channel/unix_datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,22 @@ impl<T: Send + Sync + Debug> Default for Configuration<T> {
impl<T: Send + Sync + Debug> DynamicStorageConfiguration<T> for Configuration<T> {}

impl<T: Send + Sync + Debug> NamedConceptConfiguration for Configuration<T> {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path = *value;
self
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/dynamic_storage/process_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,22 @@ impl<T: Send + Sync + Debug> Default for Configuration<T> {
impl<T: Send + Sync + Debug> DynamicStorageConfiguration<T> for Configuration<T> {}

impl<T: Send + Sync + Debug> NamedConceptConfiguration for Configuration<T> {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
18 changes: 9 additions & 9 deletions iceoryx2-cal/src/event/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ pub mod details {
{
fn convert(&self) -> <Storage as NamedConceptMgmt>::Configuration {
<Storage as NamedConceptMgmt>::Configuration::default()
.prefix(self.prefix)
.suffix(self.suffix)
.path_hint(self.path)
.prefix(&self.prefix)
.suffix(&self.suffix)
.path_hint(&self.path)
}
}

Expand Down Expand Up @@ -133,22 +133,22 @@ pub mod details {
Storage: DynamicStorage<Management<Tracker, WaitMechanism>>,
> NamedConceptConfiguration for Configuration<Tracker, WaitMechanism, Storage>
{
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path = *value;
self
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/event/process_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path = *value;
self
}

Expand Down
14 changes: 7 additions & 7 deletions iceoryx2-cal/src/event/unix_datagram_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn path_hint(mut self, value: Path) -> Self {
self.path = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path = *value;
self
}

Expand All @@ -71,7 +71,7 @@ impl NamedConceptConfiguration for Configuration {

impl From<Configuration> for crate::communication_channel::unix_datagram::Configuration {
fn from(value: Configuration) -> Self {
Self::default().suffix(value.suffix).path_hint(value.path)
Self::default().suffix(&value.suffix).path_hint(&value.path)
}
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/monitoring/file_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,26 +339,26 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn get_suffix(&self) -> &FileName {
&self.suffix
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-cal/src/monitoring/process_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ impl Default for Configuration {
}

impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
fn prefix(mut self, value: &FileName) -> Self {
self.prefix = *value;
self
}

fn get_prefix(&self) -> &FileName {
&self.prefix
}

fn suffix(mut self, value: FileName) -> Self {
self.suffix = value;
fn suffix(mut self, value: &FileName) -> Self {
self.suffix = *value;
self
}

fn get_suffix(&self) -> &FileName {
&self.suffix
}

fn path_hint(mut self, value: Path) -> Self {
self.path_hint = value;
fn path_hint(mut self, value: &Path) -> Self {
self.path_hint = *value;
self
}

Expand Down
6 changes: 3 additions & 3 deletions iceoryx2-cal/src/named_concept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ pub enum NamedConceptPathHintRemoveError {
/// underlying resource does not support it.
pub trait NamedConceptConfiguration: Default + Clone + Debug {
/// Defines the prefix that the concept will use.
fn prefix(self, value: FileName) -> Self;
fn prefix(self, value: &FileName) -> Self;

/// Returns the configurations prefix.
fn get_prefix(&self) -> &FileName;

/// Defines the suffix that the concept will use.
fn suffix(self, value: FileName) -> Self;
fn suffix(self, value: &FileName) -> Self;

/// Sets a path hint under which the underlying resources shall be stored. When the concept
/// uses resources like [`iceoryx2_bb_posix::shared_memory::SharedMemory`] the path will be
/// ignored.
fn path_hint(self, value: Path) -> Self;
fn path_hint(self, value: &Path) -> Self;

/// Returns the configurations suffix.
fn get_suffix(&self) -> &FileName;
Expand Down
Loading

0 comments on commit b4b8d9c

Please sign in to comment.