write_to_file/
traits.rs

1use std::path::Path;
2
3/// trait version of `write_to_file`.
4/// See also: `write_to_file::write_to_file`
5pub trait WriteToFile
6{
7 fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), std::io::Error>;
8}
9
10/// impl Vec<u8> version of trait of `write_to_file`.
11/// See also: `write_to_file::write_to_file`
12impl WriteToFile for Vec<u8>
13{
14 fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), std::io::Error>
15 {
16  crate::write_to_file(path, self)
17 }
18}
19
20/// impl &[u8] version of trait of `write_to_file`.
21/// See also: `write_to_file::write_to_file`
22impl WriteToFile for &[u8]
23{
24 fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), std::io::Error>
25 {
26  crate::write_to_file(path, self)
27 }
28}
29
30/// impl String version of trait of `write_to_file`.
31/// See also: `write_to_file::write_to_file`
32impl WriteToFile for String
33{
34 fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), std::io::Error>
35 {
36  crate::write_to_file(path, self)
37 }
38}
39
40/// impl &str version of trait of `write_to_file`.
41/// See also: `write_to_file::write_to_file`
42impl WriteToFile for &str
43{
44 fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), std::io::Error>
45 {
46  crate::write_to_file(path, self)
47 }
48}