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

Options fix #427

Merged
merged 3 commits into from
Jun 7, 2024
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: 6 additions & 12 deletions src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,20 @@ pub unsafe extern "C" fn z_get(
let key_expr = key_expr.transmute_ref();
let mut get = session.get(Selector::new(key_expr, p));
if let Some(options) = options {
if let Some(payload) = options.payload.as_mut() {
if let Some(payload) = unsafe { options.payload.as_mut() } {
let payload = payload.transmute_mut().extract();
get = get.payload(payload);
}
if let Some(encoding) = options.encoding.as_mut() {
if let Some(encoding) = unsafe { options.encoding.as_mut() } {
let encoding = encoding.transmute_mut().extract();
get = get.encoding(encoding);
}
if !options.source_info.is_null() {
let source_info = unsafe { options.source_info.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(source_info) = unsafe { options.source_info.as_mut() } {
let source_info = source_info.transmute_mut().extract();
get = get.source_info(source_info);
}
if !options.attachment.is_null() {
let attachment = unsafe { options.attachment.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(attachment) = unsafe { options.attachment.as_mut() } {
let attachment = attachment.transmute_mut().extract();
get = get.attachment(attachment);
}

Expand Down
6 changes: 2 additions & 4 deletions src/publication_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ pub extern "C" fn ze_declare_publication_cache(
if options.resources_limit != 0 {
p = p.resources_limit(options.resources_limit)
}
if !options.queryable_prefix.is_null() {
let queryable_prefix = unsafe { options.queryable_prefix.as_ref() }
.unwrap()
.transmute_ref();
if let Some(queryable_prefix) = unsafe { options.queryable_prefix.as_ref() } {
let queryable_prefix = queryable_prefix.transmute_ref();
p = p.queryable_prefix(queryable_prefix.clone());
}
}
Expand Down
23 changes: 7 additions & 16 deletions src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,16 @@ pub unsafe extern "C" fn z_publisher_put(

let mut put = publisher.put(payload);
if let Some(options) = options {
if !options.encoding.is_null() {
let encoding = unsafe { options.encoding.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(encoding) = unsafe { options.encoding.as_mut() } {
let encoding = encoding.transmute_mut().extract();
put = put.encoding(encoding);
};
if !options.source_info.is_null() {
let source_info = unsafe { options.source_info.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(source_info) = unsafe { options.source_info.as_mut() } {
let source_info = source_info.transmute_mut().extract();
put = put.source_info(source_info);
}
if !options.attachment.is_null() {
let attachment = unsafe { options.attachment.as_mut() }
.unwrap()
.transmute_mut()
.extract();
};
if let Some(attachment) = unsafe { options.attachment.as_mut() } {
let attachment = attachment.transmute_mut().extract();
put = put.attachment(attachment);
}
}
Expand Down
220 changes: 0 additions & 220 deletions src/pull_subscriber.rs

This file was deleted.

21 changes: 6 additions & 15 deletions src/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,16 @@ pub extern "C" fn z_put(

let mut put = session.put(key_expr, payload);
if let Some(options) = options {
if !options.encoding.is_null() {
let encoding = unsafe { options.encoding.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(encoding) = unsafe { options.encoding.as_mut() } {
let encoding = encoding.transmute_mut().extract();
put = put.encoding(encoding);
};
if !options.source_info.is_null() {
let source_info = unsafe { options.source_info.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(source_info) = unsafe { options.source_info.as_mut() } {
let source_info = source_info.transmute_mut().extract();
put = put.source_info(source_info);
};
if !options.attachment.is_null() {
let attachment = unsafe { options.attachment.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(attachment) = unsafe { options.attachment.as_mut() } {
let attachment = attachment.transmute_mut().extract();
put = put.attachment(attachment);
}
put = put.priority(options.priority.into());
Expand Down
23 changes: 7 additions & 16 deletions src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub extern "C" fn z_queryable_check(this: &z_owned_queryable_t) -> bool {
/// @return 0 in case of success, negative error code otherwise.
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn z_query_reply(
pub extern "C" fn z_query_reply(
this: &z_loaned_query_t,
key_expr: &z_loaned_keyexpr_t,
payload: &mut z_owned_bytes_t,
Expand All @@ -244,25 +244,16 @@ pub unsafe extern "C" fn z_query_reply(

let mut reply = query.reply(key_expr, payload);
if let Some(options) = options {
if !options.encoding.is_null() {
let encoding = unsafe { options.encoding.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(encoding) = unsafe { options.encoding.as_mut() } {
let encoding = encoding.transmute_mut().extract();
reply = reply.encoding(encoding);
};
if !options.source_info.is_null() {
let source_info = unsafe { options.source_info.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(source_info) = unsafe { options.source_info.as_mut() } {
let source_info = source_info.transmute_mut().extract();
reply = reply.source_info(source_info);
};
if !options.attachment.is_null() {
let attachment = unsafe { options.attachment.as_mut() }
.unwrap()
.transmute_mut()
.extract();
if let Some(attachment) = unsafe { options.attachment.as_mut() } {
let attachment = attachment.transmute_mut().extract();
reply = reply.attachment(attachment);
}
}
Expand Down
Loading
Loading