decode method
Implementation
@override
Future<Reply> decode(EncodedContent encodedContent) async {
final reference = encodedContent.parameters['reference'];
if (reference == null) {
throw Exception('Reply: Invalid Content: missing reference');
}
// Parse the nested EncodedContent from bytes
// The bytes contain a complete EncodedContent protobuf, not just raw content
final replyEncodedContent = EncodedContent.fromBuffer(encodedContent.content);
// Get the codec for the nested content type
final replyCodec = codecRegistry.getCodec(
replyEncodedContent.type.authorityId,
replyEncodedContent.type.typeId,
);
if (replyCodec == null) {
throw Exception('Reply: No codec found for content type: ${replyEncodedContent.type.authorityId}/${replyEncodedContent.type.typeId}');
}
// Decode the nested content using its codec (recursive)
final replyContent = await replyCodec.decode(replyEncodedContent);
return Reply(
reference: reference,
content: replyContent,
contentType: ContentType(
authorityId: replyEncodedContent.type.authorityId,
typeId: replyEncodedContent.type.typeId,
versionMajor: replyEncodedContent.type.versionMajor,
),
);
}