How to fill Rust function pointer from C++

I want to call C++ from Rust. C++ then allocates and fills a buffer, then Rust uses it and deallocates. However, I'd like to deliver back the function pointer to deallocate the data. This is what I tried:

In Rust:

extern "C" {
    pub fn openvpn_receive(
        instance: *mut OpenVpnInstance,
        size: *mut size_t,
        deallocate: extern "C" fn(*mut u8),
    ) -> *mut u8;
}

fn main() {
    let size: *mut size_t;
    let deallocate = extern "C" fn(*mut u8);
    let data: *mut u8 = openvpn_receive(self.instance, size, deallocate);
    //use data
    deallocate(data);
}

In C++:

uint8_t* openvpn_receive(size_t *size, void (*deallocate_function)(uint8_t *))
{
    deallocate_function = &cpp_deallocate_u8;
    uint8*t data = receive_data(size);
}

But the Rust code is not valid. How can I make such thing happen?

How about this?

extern "C" {
    pub fn openvpn_receive(
        instance: *mut OpenVpnInstance,
        size: *mut size_t,
        deallocate: *mut extern "C" fn(*mut u8),
    ) -> *mut u8;
}

extern "C" fn dummy(_: *mut u8) {}

fn main() {
    let size: *mut size_t;
    let deallocate: extern "C" fn(*mut u8) = dummy;
    let data: *mut u8 = openvpn_receive(self.instance, size, &mut deallocate);
    //use data
    deallocate(data);
}