Skip to main content

haste_health/
utilities.rs

1use std::io::{BufReader, Read};
2
3use haste_fhir_model::r4::generated::terminology::IssueType;
4use haste_fhir_operation_error::OperationOutcomeError;
5
6pub fn read_stdin(k: &mut String) -> Result<(), OperationOutcomeError> {
7    let stdin = std::io::stdin();
8    let mut reader = BufReader::new(stdin);
9
10    reader.read_to_string(k).map_err(|e| {
11        OperationOutcomeError::error(
12            IssueType::exception(),
13            format!("Failed to read from stdin: {}", e),
14        )
15    })?;
16
17    Ok(())
18}