pub async fn save_to_disk_async(
index: OfficialIndex,
path: PathBuf,
) -> Result<()>Expand description
What: Persist an official package index to disk asynchronously.
Inputs:
index: The index to serialize and write (moved into the blocking task).path: File path to write the JSON index to.
Output:
- Returns a future resolving to
Result<()>(same semantics assave_to_disk).
Details:
- Uses
tokio::task::spawn_blockingto avoid blocking the async runtime on file I/O. - Takes the index by value because the blocking task requires
'staticdata; clone before calling if the index is still needed.
§Errors
Returns an error if the blocking task fails, the parent directory cannot be created, serialization fails, or the file cannot be written.
§Example
use arch_toolkit::index::{save_to_disk_async, OfficialIndex};
use std::path::PathBuf;
let index = OfficialIndex::default();
save_to_disk_async(index, PathBuf::from("official_index.json")).await?;