toString method

  1. @override
String toString()
override

Renders this encoding the way canon composes one, so display and wire agree.

With no raw schema, mimeType verbatim. Otherwise mimeType up to but excluding its first ;, then ;, then the raw schema -- canon's z_encoding_set_schema_from_substr REPLACES rather than appends, so Encoding('text/plain;old').withSchema('new') renders text/plain;new and agrees with what the wire carries. A naive concatenation would render text/plain;old;new and contradict it.

Implementation

@override
String toString() {
  final raw = _schema;
  if (raw == null) return mimeType;
  final separator = mimeType.indexOf(_schemaSeparator);
  final base = separator < 0 ? mimeType : mimeType.substring(0, separator);
  return '$base$_schemaSeparator$raw';
}