backgroundassets-rs
Safe Rust bindings for Apple's BackgroundAssets framework — on-demand asset packs, manifest parsing, managed asset-pack availability, downloader-extension bridging, and URL download descriptors on macOS.
Status: v0.1.0 wraps the asset-pack surface needed by
foundation-models-rs, plusBADownload,BAURLDownload,BADownloadManager,BAAppExtensionInfo, and a Rust-hostedBADownloaderExtensionadapter.
Quick start
= { = "0.1", = ["async"] }
use ;
Feature table
| Area | Surface |
|---|---|
| Asset packs | AssetPack, AssetPackStatus, Manifest, AssetPackManager |
| Downloads | Download, UrlDownload, DownloadManager, DownloadPriority, DownloadStatus |
| Extension metadata | AppExtensionInfo, AuthenticationChallenge, ChallengeDisposition |
| Async workflows | AssetPackManager async methods, status-update streams, DownloadManager::current_downloads, downloader-extension event stream (requires async) |
| Rust-hosted extension | install_global_downloader_extension + Swift principal class BackgroundAssetsRustDownloaderExtension (requires async for events) |
Highlights
- Safe opaque wrappers for
AssetPack,Manifest,Download,UrlDownload,DownloadManager,AssetPackManager, andBAAppExtensionInfo. - Executor-agnostic async wrappers backed by Swift
Taskthunks anddoom-fish-utils::completion::AsyncCompletion. - Managed asset-pack status streaming backed by
doom-fish-utils::stream::BoundedAsyncStream. - Rust-side
BADownloaderExtensionhandler registration for extension code that wants to keep its scheduling logic in Rust. - Typed error payloads that preserve the framework error domain, numeric code, message, asset-pack identifier, and file path metadata.
Examples
All examples require the async feature:
01_list_pack_status02_download_pack03_extension_handler
Run them with:
Availability
- The crate targets the Background Assets surface shipped in the macOS 26 SDK.
BADownload,BAURLDownload, andBADownloadManagerare available on earlier macOS releases in the Apple SDK, but the asset-pack surface (AssetPack,Manifest,AssetPackManager) requires macOS 26.AssetPackManager::status_relative_to,local_status,asset_pack_is_available_locally, andensure_local_availability(..., require_latest = true)require macOS 26.4 at runtime because that is where Apple introduced those APIs.
Extension integration
The Swift bridge exports a ready-to-use principal class named BackgroundAssetsRustDownloaderExtension. To use it in an app extension:
- Link the Rust crate into the extension target.
- Set
EXPrincipalClasstoBackgroundAssetsRustDownloaderExtensionin the extension'sInfo.plist. - Register a Rust handler at startup with
install_global_downloader_extension(...).
See examples/03_extension_handler.rs for the Rust side of the pattern.
Coverage
See COVERAGE.md and COVERAGE_AUDIT.md for the audited SDK surface and documented gaps.
License
Licensed under either Apache-2.0 or MIT at your option.