toCbor method

  1. @override
CborObject toCbor()
override

Converts the object to a CBOR object.

Implementation

@override
CborObject toCbor() {
  final obj = () {
    switch (serializationConfig.encoding) {
      case CborIterableEncodingType.inDefinite:
        return CborListValue.inDefinite(
            credentials.map((e) => e.toCbor()).toList());
      case CborIterableEncodingType.definite:
        return CborListValue.definite(
            credentials.map((e) => e.toCbor()).toList());
      case CborIterableEncodingType.set:
        return CborSetValue(credentials.map((e) => e.toCbor()));
    }
  }() as CborObject;
  final tags = serializationConfig.tags;
  if (tags != null) {
    return CborTagValue(obj, tags);
  }
  return obj;
}