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}
12
13impl Write for FileWrite {
14 fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
15 match &mut self.inner {
16 FileWriteInner::Local(local) => local.write(buf),
17 }
18 }
19
20 fn flush(&mut self) -> std::io::Result<()> {
21 match &mut self.inner {
22 FileWriteInner::Local(local) => local.flush(),
23 }
24 }
25}
26
27impl FileWrite {
28 pub fn close(self) -> Result<(), std::io::Error> {
32 match self.inner {
33 FileWriteInner::Local(local) => local.close(),
34 }
35 }
36}