- Attempt to mixin properly

This commit is contained in:
Tristan B. Velloza Kildaire 2023-01-06 16:42:40 +02:00
parent b10c7d928d
commit 3d9b9a4976
2 changed files with 15 additions and 8 deletions

View File

@ -1,10 +1,11 @@
module libpb.deserialization;
import std.json;
import std.traits : FieldTypeTuple, FieldNameTuple;
template T(RecordType)
mixin template T(RecordType)
{
import std.traits : FieldTypeTuple, FieldNameTuple;
public RecordType fromJSON(JSONValue jsonIn)
{
RecordType record;
@ -131,7 +132,8 @@ unittest
}
`);
Person person = T!(Person).fromJSON(json);
mixin T!(Person);
Person person = fromJSON(json);
debug(dbg)
{

View File

@ -158,7 +158,8 @@ public class PocketBase
}
}
recordsOut ~= T!(RecordType).fromJSON(returnedItem);
mixin T!(RecordType);
recordsOut ~= fromJSON(returnedItem);
}
return recordsOut;
@ -268,7 +269,8 @@ public class PocketBase
responseJSON["passwordConfirm"] = "";
}
recordOut = T!(RecordType).fromJSON(responseJSON);
mixin T!(RecordType);
recordOut = fromJSON(responseJSON);
return recordOut;
}
@ -349,7 +351,8 @@ public class PocketBase
}
recordOut = T!(RecordType).fromJSON(recordResponse);
mixin T!(RecordType);
recordOut = fromJSON(recordResponse);
// Store the token
token = responseJSON["token"].str();
@ -448,7 +451,8 @@ public class PocketBase
}
}
recordOut = T!(RecordType).fromJSON(responseJSON);
mixin T!(RecordType);
recordOut = fromJSON(responseJSON);
return recordOut;
}
@ -553,7 +557,8 @@ public class PocketBase
}
}
recordOut = T!(RecordType).fromJSON(responseJSON);
mixin T!(RecordType);
recordOut = fromJSON(responseJSON);
return recordOut;
}