Skip to content
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

Add z_publisher_set_* methods #429

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,24 @@ z_error_t z_publisher_put(const struct z_loaned_publisher_t *this_,
* Constructs the default value for `z_publisher_put_options_t`.
*/
ZENOHC_API void z_publisher_put_options_default(struct z_publisher_put_options_t *this_);
/**
* Sets allowed destination for the publisher
*/
ZENOHC_API
void z_publisher_set_allowed_destination(struct z_loaned_publisher_t *publisher,
enum zcu_locality_t destination);
/**
* Sets congestion control for the publisher
*/
ZENOHC_API
void z_publisher_set_congestion_control(struct z_loaned_publisher_t *publisher,
enum z_congestion_control_t congestion_control);
/**
* Sets priority for the publisher
*/
ZENOHC_API
void z_publisher_set_priority(struct z_loaned_publisher_t *publisher,
enum z_priority_t priority);
/**
* Publishes data on specified key expression.
*
Expand Down
31 changes: 30 additions & 1 deletion src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,41 @@ pub extern "C" fn z_publisher_delete(

/// Returns the key expression of the publisher.
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub extern "C" fn z_publisher_keyexpr(publisher: &z_loaned_publisher_t) -> &z_loaned_keyexpr_t {
let publisher = publisher.transmute_ref();
publisher.key_expr().transmute_handle()
}

/// Sets congestion control for the publisher
#[no_mangle]
pub extern "C" fn z_publisher_set_congestion_control(
publisher: &mut z_loaned_publisher_t,
congestion_control: z_congestion_control_t,
) {
let publisher = publisher.transmute_mut();
publisher.set_congestion_control(congestion_control.into())
}

/// Sets priority for the publisher
#[no_mangle]
pub extern "C" fn z_publisher_set_priority(
publisher: &mut z_loaned_publisher_t,
priority: z_priority_t,
) {
let publisher = publisher.transmute_mut();
publisher.set_priority(priority.into())
}

/// Sets allowed destination for the publisher
#[no_mangle]
pub extern "C" fn z_publisher_set_allowed_destination(
publisher: &mut z_loaned_publisher_t,
destination: zcu_locality_t,
) {
let publisher = publisher.transmute_mut();
publisher.set_allowed_destination(destination.into())
}

pub use crate::opaque_types::zcu_owned_matching_listener_t;
decl_transmute_owned!(
Option<MatchingListener<'static, DefaultHandler>>,
Expand Down
Loading