subscription: fix setCompletionCallback
This was not being tested, and it was really broken. Now it is being tested and it is no longer broken.
This commit is contained in:
@@ -174,12 +174,12 @@ pub const Subscription = opaque {
|
||||
self: *Subscription,
|
||||
comptime T: type,
|
||||
comptime callback: *const thunk.SimpleCallbackThunkSignature(T),
|
||||
userdata: *T,
|
||||
userdata: T,
|
||||
) Error!void {
|
||||
return Status.fromInt(nats_c.natsSubscription_SetOnCompleteCB(
|
||||
@ptrCast(self),
|
||||
thunk.makeSimpleCallbackThunk(callback),
|
||||
@constCast(userdata),
|
||||
thunk.makeSimpleCallbackThunk(T, callback),
|
||||
@constCast(@ptrCast(userdata)),
|
||||
)).raise();
|
||||
}
|
||||
};
|
||||
|
@@ -57,7 +57,7 @@ pub fn makeSimpleCallbackThunk(
|
||||
comptime checkUserDataType(T);
|
||||
return struct {
|
||||
fn thunk(userdata: ?*anyopaque) callconv(.C) void {
|
||||
const data: *T = if (userdata) |u| @alignCast(@ptrCast(u)) else unreachable;
|
||||
const data: T = if (userdata) |u| @alignCast(@ptrCast(u)) else unreachable;
|
||||
callback(data);
|
||||
}
|
||||
}.thunk;
|
||||
|
Reference in New Issue
Block a user