serializePPTFragments method
Uint8List
serializePPTFragments({
- Uint8List? argumentsBytes,
- Uint8List? argumentsKeywordsBytes,
- List? arguments,
- Map<
String, dynamic> ? argumentsKeywords,
override
Serializer PPT payload from already-encoded args / kwargs fragments when the payload serializer matches the surrounding transport serializer.
Implementation
@override
Uint8List serializePPTFragments({
Uint8List? argumentsBytes,
Uint8List? argumentsKeywordsBytes,
List<dynamic>? arguments,
Map<String, dynamic>? argumentsKeywords,
}) {
final binaryArgument =
argumentsBytes == null &&
argumentsKeywordsBytes == null &&
argumentsKeywords == null &&
arguments?.length == 1 &&
arguments!.single is Uint8List
? arguments.single as Uint8List
: null;
if (binaryArgument != null) {
return (BytesBuilder(copy: false)
..add(const [0xa2])
..add(_pptArgsKeyBytes)
..add(const [0x81])
..add(_encodeCborByteStringHeader(binaryArgument.length))
..add(binaryArgument)
..add(_pptKwargsKeyBytes)
..add(_nullBytes))
.takeBytes();
}
final argsBytes = argumentsBytes ?? _encodeCborValue(arguments);
final kwargsBytes =
argumentsKeywordsBytes ?? _encodeCborValue(argumentsKeywords);
final builder = BytesBuilder(copy: false)
..add([0xa2])
..add(_pptArgsKeyBytes)
..add(argsBytes.isEmpty ? _nullBytes : argsBytes)
..add(_pptKwargsKeyBytes)
..add(kwargsBytes.isEmpty ? _nullBytes : kwargsBytes);
return builder.takeBytes();
}