all: don't automatically convert userdata types to pointer types
One of the things I have done a better job of internalizing while working with zig over the last few months is that the less magic that exists, the better. In the case of parameterized functions, this means that it is much better to restrict the range of types that are permitted to be passed than to perform type manipulation. In other words, it's more confusing to see a function that is parameterized with `SomeType` taking a pointer to that type than having it be parameterized directly to take the pointer. Obviously there are exceptions to this rule, like std.mem.eql taking slices of its parameterized type. In fact, this new approach fixes some edge cases. Null userdata may now be passed in, since the user can now actually specify an optional pointer type (e.g. `?*void` may be used to provide always-null userdata). Additionally, a pointer to a constant value can now be passed in, which wasn't possible before (this could have been worked around by use of constCast and being careful, but that's an exceedingly bad option compared to having the type system work for you).
This commit is contained in:
@@ -164,14 +164,14 @@ test "nats.ConnectionOptions" {
|
||||
try options.setMaxReconnect(10);
|
||||
try options.setReconnectWait(500);
|
||||
try options.setReconnectJitter(100, 200);
|
||||
try options.setCustomReconnectDelay(u32, reconnectDelayHandler, &userdata);
|
||||
try options.setCustomReconnectDelay(*u32, reconnectDelayHandler, &userdata);
|
||||
try options.setReconnectBufSize(1024);
|
||||
try options.setMaxPendingMessages(50);
|
||||
try options.setErrorHandler(u32, errorHandler, &userdata);
|
||||
try options.setClosedCallback(u32, connectionHandler, &userdata);
|
||||
try options.setDisconnectedCallback(u32, connectionHandler, &userdata);
|
||||
try options.setDiscoveredServersCallback(u32, connectionHandler, &userdata);
|
||||
try options.setLameDuckModeCallback(u32, connectionHandler, &userdata);
|
||||
try options.setErrorHandler(*u32, errorHandler, &userdata);
|
||||
try options.setClosedCallback(*u32, connectionHandler, &userdata);
|
||||
try options.setDisconnectedCallback(*u32, connectionHandler, &userdata);
|
||||
try options.setDiscoveredServersCallback(*u32, connectionHandler, &userdata);
|
||||
try options.setLameDuckModeCallback(*u32, connectionHandler, &userdata);
|
||||
try options.ignoreDiscoveredServers(true);
|
||||
try options.useGlobalMessageDelivery(false);
|
||||
try options.ipResolutionOrder(.ipv4_first);
|
||||
@@ -179,8 +179,8 @@ test "nats.ConnectionOptions" {
|
||||
try options.useOldRequestStyle(false);
|
||||
try options.setFailRequestsOnDisconnect(true);
|
||||
try options.setNoEcho(true);
|
||||
try options.setRetryOnFailedConnect(u32, connectionHandler, true, &userdata);
|
||||
try options.setUserCredentialsCallbacks(u32, u32, jwtHandler, signatureHandler, &userdata, &userdata);
|
||||
try options.setRetryOnFailedConnect(*u32, connectionHandler, true, &userdata);
|
||||
try options.setUserCredentialsCallbacks(*u32, *u32, jwtHandler, signatureHandler, &userdata, &userdata);
|
||||
try options.setWriteDeadline(5);
|
||||
try options.disableNoResponders(true);
|
||||
try options.setCustomInboxPrefix("_FOOBOX");
|
||||
@@ -200,7 +200,7 @@ test "nats.ConnectionOptions (crypto edition)" {
|
||||
defer options.destroy();
|
||||
var userdata: u32 = 0;
|
||||
|
||||
try options.setTokenHandler(u32, tokenHandler, &userdata);
|
||||
try options.setTokenHandler(*u32, tokenHandler, &userdata);
|
||||
try options.setSecure(false);
|
||||
try options.setCertificatesChain(rsa_cert, rsa_key);
|
||||
try options.setCiphers("-ALL:HIGH");
|
||||
|
@@ -113,7 +113,7 @@ test "nats.Subscription (async)" {
|
||||
|
||||
{
|
||||
var count: u32 = 0;
|
||||
const subscription = try connection.subscribe(u32, message_subject, onMessage, &count);
|
||||
const subscription = try connection.subscribe(*u32, message_subject, onMessage, &count);
|
||||
defer subscription.destroy();
|
||||
|
||||
const response = try connection.requestMessage(message, 1000);
|
||||
@@ -126,7 +126,7 @@ test "nats.Subscription (async)" {
|
||||
{
|
||||
var count: u32 = 0;
|
||||
const subscription = try connection.subscribeTimeout(
|
||||
u32,
|
||||
*u32,
|
||||
message_subject,
|
||||
1000,
|
||||
onMessage,
|
||||
@@ -144,7 +144,7 @@ test "nats.Subscription (async)" {
|
||||
{
|
||||
var count: u32 = 0;
|
||||
const subscription = try connection.queueSubscribe(
|
||||
u32,
|
||||
*u32,
|
||||
message_subject,
|
||||
"queuegroup",
|
||||
onMessage,
|
||||
@@ -162,7 +162,7 @@ test "nats.Subscription (async)" {
|
||||
{
|
||||
var count: u32 = 0;
|
||||
const subscription = try connection.queueSubscribeTimeout(
|
||||
u32,
|
||||
*u32,
|
||||
message_subject,
|
||||
"queuegroup",
|
||||
1000,
|
||||
|
Reference in New Issue
Block a user