file_storage/op/file/write/
file_write.rs1use crate::system::LocalFileWrite;
2use std::io::Write;
3
4pub struct FileWrite {
6 pub(crate) inner: FileWriteInner,
7}
8
9pub(crate) enum FileWriteInner {
10 Local(LocalFileWrite),
11 }
13
14impl Write for FileWrite {
15 fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
16 match &mut self.inner {
17 FileWriteInner::Local(local) => local.write(buf),
18 }
19 }
20
21 fn flush(&mut self) -> std::io::Result<()> {
22 match &mut self.inner {
23 FileWriteInner::Local(local) => local.flush(),
24 }
25 }
26}
27
28impl FileWrite {
29 pub fn close(self) -> Result<(), std::io::Error> {
33 match self.inner {
34 FileWriteInner::Local(local) => local.close(),
35 }
36 }
37}