protocol: use Option<fn()> for nullable function

This should have the same memory layoutas a simple `fn()`
with NULL function pointers mapping to None.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-03-15 14:21:12 +01:00
parent 33b1767d05
commit 7b7a42b467
1 changed files with 1 additions and 7 deletions

View File

@ -189,14 +189,8 @@ pub extern "C" fn proxmox_backup_new(
opaque: *mut c_void, opaque: *mut c_void,
read: ReadFn, read: ReadFn,
write: WriteFn, write: WriteFn,
drop: DropFn, drop: Option<DropFn>,
) -> *mut CClient { ) -> *mut CClient {
let drop_ptr: *const () = unsafe { std::mem::transmute(drop) };
let drop = if drop_ptr.is_null() {
None
} else {
Some(drop)
};
make_c_client(crate::Client::new(CApiSocket { make_c_client(crate::Client::new(CApiSocket {
opaque, opaque,
read, read,