6941bccde4
Protobuf 3.15 introduced support for marking scalar fields like uint32 as optional, and all of our tooling appears to support it now. This allows us to use simple optional/null checks in our Rust/ TypeScript code, without having to resort to an inner message. I had to apply a minor patch to protobufjs to get this working with the json-module output; this has also been submitted upstream: https://github.com/protobufjs/protobuf.js/pull/1693 I've modified CardStatsResponse as an example of the new syntax. One thing to note: while the Rust and TypeScript bindings use optional/ null fields, as that is the norm in those languages, Google's Python bindings are not very Pythonic. Referencing an optional field that is missing will yield the default value, and a separate HasField() call is required, eg: ``` >>> from anki.stats_pb2 import CardStatsResponse as R ... msg = R.FromString(b"") ... print(msg.first_review) ... print(msg.HasField("first_review")) 0 False ``` |
||
---|---|---|
.. | ||
i18n | ||
bridgecommand.ts | ||
BUILD.bazel | ||
cards.ts | ||
children-access.ts | ||
context-keys.ts | ||
cross-browser.ts | ||
dom.ts | ||
events.ts | ||
functional.ts | ||
genfluent.py | ||
globals.ts | ||
helpers.ts | ||
image-import.d.ts | ||
keys.ts | ||
nightmode.ts | ||
node.ts | ||
platform.ts | ||
postrequest.ts | ||
promise.ts | ||
proto.ts | ||
runtime-require.ts | ||
shadow-dom.d.ts | ||
shortcuts.ts | ||
time.test.ts | ||
time.ts | ||
tsconfig.json | ||
typing.ts | ||
ui.ts | ||
uuid.ts | ||
wrap.ts |