Skip to main content

rivet_cli/destination/
stdout.rs

1use std::io::Write;
2use std::path::Path;
3
4use crate::error::Result;
5
6pub struct StdoutDestination;
7
8impl StdoutDestination {
9    pub fn new() -> Result<Self> {
10        Ok(Self)
11    }
12}
13
14impl super::Destination for StdoutDestination {
15    fn write(&self, local_path: &Path, _remote_key: &str) -> Result<()> {
16        let mut src = std::fs::File::open(local_path)?;
17        let stdout = std::io::stdout();
18        let mut handle = stdout.lock();
19        std::io::copy(&mut src, &mut handle)?;
20        handle.flush()?;
21        Ok(())
22    }
23}