-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: [#500] Expose UniquePortId bytes in CXX API #501
base: main
Are you sure you want to change the base?
WIP: [#500] Expose UniquePortId bytes in CXX API #501
Conversation
|
||
let h = &mut *handle.as_type(); | ||
|
||
if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option<UniquePublisherId>).as_ref() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of ugly IMO, can anyone suggest any better approaches offered by Rust?
@@ -43,6 +46,15 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) | |||
: m_handle { handle } { | |||
} | |||
|
|||
auto UniquePublisherId::bytes() -> iox::optional<std::array<uint8_t, UNIQUE_PORT_ID_LENGTH>> { | |||
if (m_handle != nullptr) { | |||
std::array<uint8_t, UNIQUE_PORT_ID_LENGTH> unique_port_id {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially wanted the Rust layer to just provide a pointer to the ID bytes, however I couldn't work out how to resolve the ownership between the two layers, so I opted for a copy instead.
Do you see any better options?
I implemented the API for EDIT: I went ahead and implemented a rest to unblock myself. Let me know if you see a better way though. |
33b1d13
to
515da9d
Compare
#include "iox2/internal/iceoryx2.hpp" | ||
|
||
#include <array> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially tried to use iox::vector
but didn't work out how to set the bytes properly without vector::empty
returning false.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #501 +/- ##
==========================================
- Coverage 79.21% 79.20% -0.02%
==========================================
Files 200 200
Lines 23728 23731 +3
==========================================
Hits 18795 18795
- Misses 4933 4936 +3
|
515da9d
to
2d1b857
Compare
…queNotifierId UniqueListenerId bytes in CXX API
2d1b857
to
ebc2875
Compare
@@ -36,9 +45,9 @@ class UniquePublisherId { | |||
void drop(); | |||
|
|||
iox2_unique_publisher_id_h m_handle = nullptr; | |||
iox::optional<RawIdType> m_raw_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the ID is const in Rust, it will be copied into the CXX layer on first access and the copy re-used for subsequent calls to bytes()
.
Notes for Reviewer
Provides an API to access the bytes representing a
UniquePortId
from the CXX API.Pre-Review Checklist for the PR Author
SPDX-License-Identifier: Apache-2.0 OR MIT
iox2-123-introduce-posix-ipc-example
)[#123] Add posix ipc example
)task-list-completed
)Checklist for the PR Reviewer
Post-review Checklist for the PR Author
References
Closes #500