desrialize<T extends CborObject<Object?>> static method

T desrialize<T extends CborObject<Object?>>(
  1. List<int> cborBytes
)

Deserialize the provided CBOR bytes cborBytes into an object of type T. Throws a MessageException with a descriptive message if deserialization fails.

Implementation

static T desrialize<T extends CborObject>(List<int> cborBytes) {
  final decode = CborObject.fromCbor(cborBytes);
  if (decode is! T) {
    throw CborSerializationException(
      'Failed to deserialize CBOR bytes into type.',
      details: {'type': '$T', 'expected': decode.runtimeType},
    );
  }
  return decode;
}