enforceWireVersionConstraints

Unsets nullable fields not matching the server version as defined per UDAs.

@safe
void
enforceWireVersionConstraints
(
T
)
(
ref T field
,
WireVersion serverVersion
,
string file = __FILE__
,
size_t line = __LINE__
)

Examples

struct SomeMongoCommand
{
	@embedNullable @since(WireVersion.v34)
	Nullable!int a;

	@embedNullable @until(WireVersion.v30)
	Nullable!int b;
}

SomeMongoCommand cmd;
cmd.a = 1;
cmd.b = 2;
assert(!cmd.a.isNull);
assert(!cmd.b.isNull);

SomeMongoCommand test = cmd;
enforceWireVersionConstraints(test, WireVersion.v30);
assert(test.a.isNull);
assert(!test.b.isNull);

test = cmd;
enforceWireVersionConstraints(test, WireVersion.v32);
assert(test.a.isNull);
assert(test.b.isNull);

test = cmd;
enforceWireVersionConstraints(test, WireVersion.v34);
assert(!test.a.isNull);
assert(test.b.isNull);

Meta