Skip to main content

detect_backend_with_options

Function detect_backend_with_options 

Source
pub async fn detect_backend_with_options(
    target_os: ImageOs,
    options: Option<&BuildOptions>,
) -> Result<Arc<dyn BuildBackend>>
Expand description

Auto-detect the best available build backend, honoring an optional per-build override on BuildOptions::backend_override.

Selection precedence:

  1. BuildOptions::backend_override (when options is Some).
  2. ZLAYER_BACKEND environment variable.
  3. The host × target auto-detect matrix documented on detect_backend.

When the precedence falls on step 1 or 2 (an explicit operator choice), the requested backend is constructed unconditionally — we do not silently fall back to a different kind. If the requested backend is later found to be unavailable, the actual build call will surface the failure rather than letting auto-fallback mask the operator’s intent.

§Errors

Returns BuildError::NotSupported when the requested (or auto-selected) backend kind cannot be paired with target_os on this host, and bubbles any constructor error from the chosen backend.