Skip to main content

emit

Function emit 

Source
pub fn emit(content: &str, writer: impl Write) -> Result<()>
Expand description

Write rendered output to a writer.

This function writes the rendered content to any type implementing std::io::Write, such as files or stdout.

§Parameters

  • content: The rendered content to write
  • writer: Any type implementing Write

§Returns

  • Ok(()) on success
  • Err(std::io::Error) if writing fails

§Example

use secreport::render::emit;

let content = "Security Report\n===============";
let mut output = Vec::new();

emit(content, &mut output).unwrap();
assert_eq!(String::from_utf8(output).unwrap(), content);

Writing to stdout:

use secreport::render::emit;
use std::io;

emit("Report complete!\n", io::stdout())?;