Then, at the moment it won't work because trade_event doesn't implement CType. Although CType is public but high::Type::make is not hence it is not possible to implement CType outside of the crate.
After this change, users are able to implement CType on their own. For example,
unsafe impl CType for trade_event {
fn reify() -> libffi::high::Type<Self> {
libffi::high::Type::make(libffi::middle::Type::structure([
libffi::middle::Type::u64(), // size
libffi::middle::Type::u64(), // price
libffi::middle::Type::c_uint(), // side
]))
}
type RetType = trade_event;
}
Now that trade_event implements CType, it is possible to construct the function pointer as shown above for event_handler.
This is to provide a solution for https://github.com/tov/libffi-rs/issues/48
In projects that uses
bindgen
, it would generate structs such asand if one has a function pointer such as
Then, at the moment it won't work because
trade_event
doesn't implementCType
. AlthoughCType
is public buthigh::Type::make
is not hence it is not possible to implementCType
outside of the crate.After this change, users are able to implement
CType
on their own. For example,Now that
trade_event
implementsCType
, it is possible to construct the function pointer as shown above forevent_handler
.