A decodeMessageWithCallback <A>(IncomingMessage message, int inlineSize, A f(Decoder decoder))
Decodes a FIDL message with multiple parameters. The callback parameter
provides a decoder that is initialized on the provided Message, which
callers can use to decode specific types. The return result of the callback
(e.g. the decoded parameters, wrapped in a containing class/struct) is
returned as the result of the function. This functionality (decoding
multiple parameters) is implemented using a callback because returning a
list would be insufficient: the list would be of type List
Implementation
A decodeMessageWithCallback<A>(
IncomingMessage message, int inlineSize, A Function(Decoder decoder) f) {
final int size = kMessageHeaderSize + inlineSize;
final Decoder decoder = Decoder(message)..claimBytes(size, 0);
A out = f(decoder);
final int padding = align(size) - size;
decoder.checkPadding(size, padding);
_validateDecoding(decoder);
return out;
}