Function process_json_file

Source
pub async fn process_json_file<F, Fut>(
    file_path: &Path,
    processor: F,
) -> Result<()>
where F: FnOnce(Value) -> Fut + Send, Fut: Future<Output = Result<()>> + Send,
Expand description

Processes a JSON file using a provided async processor function.

This function reads a JSON file, parses it, and applies a custom processor function to the parsed data. The processor function can perform any desired transformations or operations on the JSON data.

§Type Parameters

  • F - The processor function type
  • Fut - The future type returned by the processor function

§Arguments

  • file_path - Path to the JSON file to process
  • processor - Async function that processes the parsed JSON data

§Returns

  • io::Result<()> - Success or failure of the operation

§Errors

Returns an error if:

  • The file cannot be read
  • The content cannot be parsed as JSON
  • The processor function returns an error