Skip to main content

load_from_file

Function load_from_file 

Source
pub fn load_from_file(file_path: &Path) -> Result<Resource, String>
Expand description

Loads a FHIR resource from a JSON file.

The file is read as UTF-8 text and deserialized into a [Resource] using serde_json.

§Arguments

  • file_path - The path to the JSON file containing the FHIR resource.

§Errors

Returns an error if:

  • The file cannot be read from the provided path.
  • The file contents cannot be parsed as valid JSON.
  • The parsed JSON does not match the expected [Resource] structure.

The returned error message includes the underlying cause of the failure.