Skip to content

Conversation

@elfenpiff
Copy link
Contributor

Notes for Reviewer

  • Introduces an API compatible (to Option) ZeroCopySend capable StaticOption
  • remove Option and Duration from ZeroCopySend trait default impl
  • Introduces a StaticDuration that implements ZeroCopySend.

Pre-Review Checklist for the PR Author

  • Add sensible notes for the reviewer
  • PR title is short, expressive and meaningful
  • Consider switching the PR to a draft (Convert to draft)
    • as draft PR, the CI will be skipped for pushes
  • Relevant issues are linked in the References section
  • Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  • Commits messages are according to this guideline
    • Commit messages have the issue ID ([#123] Add posix ipc example)
    • Keep in mind to use the same email that was used to sign the Eclipse Contributor Agreement
  • Tests follow the best practice for testing
  • Changelog updated in the unreleased section including API breaking changes
  • Assign PR to reviewer
  • All checks have passed (except task-list-completed)

PR Reviewer Reminders

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

References

Closes #1312

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #1312 by removing Option<T> and Duration from the default ZeroCopySend trait implementations and introducing zero-copy safe alternatives: StaticOption<T> and StaticDuration. These new types provide API-compatible alternatives with stable memory layouts suitable for shared memory communication.

Changes:

  • Introduced StaticOption<T> with comprehensive API matching standard Option<T>
  • Introduced StaticDuration as a zero-copy safe alternative to Duration
  • Removed Option<T>, Result<T, E>, and Duration from ZeroCopySend default implementations
  • Migrated all internal usage from Option to StaticOption in service static configurations
  • Updated event service configuration to use new zero-copy safe types

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
iceoryx2-bb/container/src/static_option.rs New StaticOption<T> implementation with full API compatibility
iceoryx2-bb/container/tests/static_option_tests.rs Comprehensive test suite for StaticOption
iceoryx2-bb/container/src/lib.rs Module export for static_option
iceoryx2-bb/posix/src/clock.rs New StaticDuration type with conversions
iceoryx2-bb/elementary-traits/src/zero_copy_send.rs Removed Option, Result, and Duration from trait implementations
iceoryx2/src/service/static_config/event.rs Migrated to StaticOption and StaticDuration in event configuration
iceoryx2/src/service/builder/event.rs Updated event builder to use new types
iceoryx2/src/service/mod.rs Updated service code to work with StaticOption
iceoryx2/src/port/notifier.rs Updated to handle StaticOption and StaticDuration conversions
iceoryx2/src/port/listener.rs Updated listener deadline handling
iceoryx2-ffi/python/src/port_factory_event.rs Changed from copy to clone for static config access
doc/release-notes/iceoryx2-unreleased.md Documented new features and API breaking changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@elfenpiff elfenpiff force-pushed the iox2-1312-no-zero-copy-send-for-option-result branch from a8e1c64 to d721733 Compare January 23, 2026 09:20
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 93.25397% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.90%. Comparing base (03b09c5) to head (045f100).
⚠️ Report is 56 commits behind head on main.

Files with missing lines Patch % Lines
iceoryx2-bb/container/src/relocatable_option.rs 95.30% 7 Missing ⚠️
iceoryx2/src/service/builder/publish_subscribe.rs 60.00% 4 Missing ⚠️
iceoryx2/src/service/builder/request_response.rs 71.42% 4 Missing ⚠️
iceoryx2/src/service/builder/blackboard.rs 85.71% 1 Missing ⚠️
iceoryx2/src/service/builder/event.rs 90.90% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1313      +/-   ##
==========================================
+ Coverage   77.86%   77.90%   +0.03%     
==========================================
  Files         405      406       +1     
  Lines       38759    38941     +182     
  Branches     1256     1265       +9     
==========================================
+ Hits        30179    30336     +157     
- Misses       7547     7801     +254     
+ Partials     1033      804     -229     
Flag Coverage Δ
CPP 68.04% <ø> (ø)
Rust 77.75% <93.25%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ceoryx2-bb/elementary-traits/src/zero_copy_send.rs 75.00% <ø> (ø)
iceoryx2-bb/posix/src/clock.rs 87.50% <100.00%> (+1.36%) ⬆️
...ceoryx2-userland/record-and-replay/src/recorder.rs 89.72% <100.00%> (ø)
iceoryx2/src/port/client.rs 91.81% <100.00%> (ø)
iceoryx2/src/port/listener.rs 89.65% <100.00%> (+0.08%) ⬆️
iceoryx2/src/port/notifier.rs 87.68% <100.00%> (+0.23%) ⬆️
iceoryx2/src/port/publisher.rs 92.70% <100.00%> (ø)
iceoryx2/src/port/server.rs 92.92% <100.00%> (ø)
iceoryx2/src/port/subscriber.rs 95.89% <100.00%> (ø)
iceoryx2/src/service/builder/mod.rs 84.36% <100.00%> (-0.73%) ⬇️
... and 14 more

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@elfenpiff elfenpiff force-pushed the iox2-1312-no-zero-copy-send-for-option-result branch from 9c36497 to 56b689f Compare January 26, 2026 12:11
Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to review the tests, but in the meantime, you can already have a look at the comments.

fn when_empty_as_option_returns_empty_option() {
let sut = RelocatableOption::<i32>::default();

assert_that!(sut.as_option_ref(), eq None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really want to check if you get an Option with a reference to the value, the current test is not sufficient. You would need to do a pattern matching in a similar way to this

Suggested change
assert_that!(sut.as_option_ref(), eq None);
assert_that!(sut.as_option_ref(), eq Option::<&i32>::None);

Same with the other tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is less of a unit test but more of an API tests, so that the function name and the return type are correct. It would be sufficient to test this once for every function since the compiler and the language ensures that this does not change during runtime thanks to no function overload, the rust compiler etc.

So I add this once, for every as_option* function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was also to get rid of the unwraps. We have too many of them already 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think that unwrap() is bad in a test?

Copy link
Member

@elBoberido elBoberido Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific case it's not that bad, because the error message will be that an empty Option is accessed. Not using unwrap would only lead to a slightly better error message. It would be just to train the muscle memory to not use unwrap.

The bigger issue is when the SUT ist not an Option but something else. For example, we have some flaky tests, which I wanted to debug but since there is an unwrap on a Result, the underlying error is hidden and it makes it hard to understand what is going on

@elfenpiff elfenpiff merged commit 967fe9f into eclipse-iceoryx:main Jan 27, 2026
43 checks passed
@elfenpiff elfenpiff deleted the iox2-1312-no-zero-copy-send-for-option-result branch January 27, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove ZeroCopySend for Optional, Result and Duration

3 participants