missingFrom method

List<CapabilityMismatch> missingFrom(
  1. DocumentRequirements requirements
)

The reasons this build cannot handle what requirements ask for.

A type this description names is checked in full: a kind it lacks, or a snapshot blob written with another layout, is a refusal. A type it does not name is a refusal only when this description is complete — see that field for why silence cannot be read as "cannot" otherwise.

An empty result means everything requirements ask for is readable here.

Implementation

List<CapabilityMismatch> missingFrom(DocumentRequirements requirements) {
  if (isEmpty) {
    return const [];
  }

  final missing = <CapabilityMismatch>[];

  for (final entry in requirements.byHandlerType.entries) {
    final mine = capabilities[entry.key];
    if (mine == null) {
      if (complete) {
        // Not one entry per kind: what is missing is the handler.
        missing.add(UnknownHandlerType(handlerType: entry.key));
      }
      continue;
    }

    for (final kind in entry.value.operationKinds) {
      if (!mine.operationKinds.contains(kind)) {
        missing.add(
          MissingOperationKind(handlerType: entry.key, kind: kind),
        );
      }
    }

    // Only when both sides state a range. A type described from change
    // envelopes alone carries no snapshot version, and silence is not a
    // disagreement.
    //
    // Two comparisons, not an intersection: this build reads everything
    // between its own ends, so the data fits when both of its ends do.
    final reads = mine.blobVersions;
    final holds = entry.value.blobVersions;
    if (reads != null && holds != null) {
      if (holds.max > reads.max) {
        missing.add(
          SnapshotBlobTooNew(
            handlerType: entry.key,
            reads: reads,
            holds: holds.max,
          ),
        );
      }
      if (holds.min < reads.min) {
        missing.add(
          SnapshotBlobTooOld(
            handlerType: entry.key,
            reads: reads,
            holds: holds.min,
          ),
        );
      }
    }
  }

  return missing;
}