]> git.proxmox.com Git - proxmox-backup.git/commitdiff
add all autotraits to output_or_stdout trait object
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 29 Sep 2021 10:39:51 +0000 (12:39 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 29 Sep 2021 11:59:02 +0000 (13:59 +0200)
just in case we ever need any of them in async code that
requires them and loses it because of accessing such a trait
object...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
pbs-tools/src/cli.rs

index 069b23e2db42c773d04226a4998a507d665a5171..62f17ac5e1ed1eaa753328a0914fa4c2b00a2e78 100644 (file)
@@ -1,13 +1,16 @@
 use std::fs::File;
 use std::io::{self, stdout, Write};
 use std::path::Path;
+use std::panic::{RefUnwindSafe, UnwindSafe};
 
 /// Returns either a new file, if a path is given, or stdout, if no path is given.
-pub fn outfile_or_stdout<P: AsRef<Path>>(path: Option<P>) -> io::Result<Box<dyn Write>> {
+pub fn outfile_or_stdout<P: AsRef<Path>>(
+    path: Option<P>,
+) -> io::Result<Box<dyn Write + Send + Sync + Unpin + RefUnwindSafe + UnwindSafe>> {
     if let Some(path) = path {
         let f = File::create(path)?;
-        Ok(Box::new(f) as Box<dyn Write>)
+        Ok(Box::new(f) as Box<_>)
     } else {
-        Ok(Box::new(stdout()) as Box<dyn Write>)
+        Ok(Box::new(stdout()) as Box<_>)
     }
 }