Skip to main content

write_line_to

Function write_line_to 

Source
pub fn write_line_to(out: &mut impl Write, content: &str) -> Result<()>
Expand description

Writes a line to an arbitrary Write with pure LF, then flushes (G-IO-11).

Dependency-injection primitive: unit tests and alternate sinks pass a Cursor/Vec/File instead of process stdout. Production paths call write_line which locks real stdout.

Prefer write_line_to_fmt / write_line_fmt when the content is built with format_args! so no intermediate String is allocated (G-MAC-01).

§Examples

use ssh_cli::output::write_line_to;
use std::io::Cursor;

let mut buf = Cursor::new(Vec::new());
write_line_to(&mut buf, "hello").unwrap();
assert_eq!(String::from_utf8(buf.into_inner()).unwrap(), "hello\n");

§Errors

Propagates I/O errors from the underlying writer (including BrokenPipe).