convert method

  1. @override
CborValue convert(
  1. List<int> input
)
override

Converts input and returns the result of the conversion.

If the input does not contain a single CBOR item, FormatException will be thrown.

Implementation

@override
CborValue convert(List<int> input) {
  CborValue? value;

  startChunkedConversion(ChunkedConversionSink.withCallback((values) {
    if (values.isEmpty) {
      throw FormatException('Expected at least one CBOR value.');
    }
    if (values.length > 1) {
      throw FormatException('Expected at most one CBOR value.');
    }

    value = values.single;
  }))
    ..add(input)
    ..close();

  return value!;
}