Skip to content

Commit

Permalink
Add publisher id getter
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jun 12, 2024
1 parent 9972ea7 commit 737b899
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,10 @@ ZENOHC_API void z_publisher_delete_options_default(struct z_publisher_delete_opt
* Frees memory and resets publisher to its gravestone state. Also attempts undeclare publisher.
*/
ZENOHC_API void z_publisher_drop(struct z_owned_publisher_t *this_);
/**
* Returns the ID of the publisher.
*/
ZENOHC_API struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher);
/**
* Returns the key expression of the publisher.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ use crate::errors;
use crate::transmute::unwrap_ref_unchecked;
use crate::transmute::unwrap_ref_unchecked_mut;
use crate::transmute::Inplace;
use crate::transmute::TransmuteCopy;
use crate::transmute::TransmuteFromHandle;
use crate::transmute::TransmuteIntoHandle;
use crate::transmute::TransmuteRef;
use crate::transmute::TransmuteUninitPtr;
use crate::z_entity_global_id_t;
use crate::z_owned_encoding_t;
use crate::z_owned_source_info_t;
use crate::z_timestamp_t;
Expand Down Expand Up @@ -270,6 +272,13 @@ pub extern "C" fn z_publisher_delete(
}
}

/// Returns the ID of the publisher.
#[no_mangle]
pub extern "C" fn z_publisher_id(publisher: &z_loaned_publisher_t) -> z_entity_global_id_t {
let publisher = publisher.transmute_ref();
publisher.id().transmute_copy()
}

/// Returns the key expression of the publisher.
#[no_mangle]
pub extern "C" fn z_publisher_keyexpr(publisher: &z_loaned_publisher_t) -> &z_loaned_keyexpr_t {
Expand Down

0 comments on commit 737b899

Please sign in to comment.