PixaRuntimePlatformSelfCheck.evaluate constructor

PixaRuntimePlatformSelfCheck.evaluate({
  1. required PixaRuntimeCapabilities capabilities,
  2. required String? cacheRootPath,
})

Evaluates runtime platform checks from the current capability snapshot.

Implementation

factory PixaRuntimePlatformSelfCheck.evaluate({
  required PixaRuntimeCapabilities capabilities,
  required String? cacheRootPath,
}) {
  final PixaRuntimePlatformStatus status = capabilities.platformStatus;
  final PixaRuntimePlatformContract? contract = status.contract;
  final List<PixaRuntimePlatformCheck> checks = <PixaRuntimePlatformCheck>[
    _platformCheck(
      name: 'runtimeLibraryLoad',
      required: contract?.runtimeLibraryLoad ?? status.isSupportedPlatform,
      passed: status.runtimeAvailable,
      passedMessage: 'runtime library loaded',
      failedMessage: status.message,
    ),
    _platformCheck(
      name: 'symbolResolution',
      required: contract?.symbolResolution ?? status.isSupportedPlatform,
      passed:
          status.runtimeAvailable &&
          capabilities.runtimePluginAbiVersion != null,
      passedMessage: 'runtime ABI symbols resolved',
      failedMessage: 'runtime ABI symbols are unavailable',
    ),
    _platformCheck(
      name: 'threadedRuntime',
      required: contract?.threadedRuntime ?? status.isSupportedPlatform,
      passed: status.runtimeAvailable && capabilities.pixelProcessors,
      passedMessage: 'runtime threaded work capabilities are available',
      failedMessage: 'runtime threaded work capabilities are unavailable',
    ),
    _platformCheck(
      name: 'cacheDirectory',
      required: contract?.cacheDirectory ?? status.isSupportedPlatform,
      passed: cacheRootPath != null && cacheRootPath.trim().isNotEmpty,
      passedMessage: 'cache directory is resolved',
      failedMessage: 'cache directory is not resolved',
    ),
    _platformCheck(
      name: 'networkPolicy',
      required: contract?.networkPolicy ?? status.isSupportedPlatform,
      passed: status.runtimeAvailable && capabilities.httpTransport,
      passedMessage: 'runtime HTTP transport is available',
      failedMessage: 'runtime HTTP transport is unavailable',
    ),
  ];
  return PixaRuntimePlatformSelfCheck(
    platform: status.platform,
    isWeb: status.isWeb,
    isSupportedPlatform: status.isSupportedPlatform,
    passed: checks.every(
      (PixaRuntimePlatformCheck check) => !check.required || check.passed,
    ),
    checks: List<PixaRuntimePlatformCheck>.unmodifiable(checks),
  );
}