pub struct WritableStream<R: Runtime> { /* private fields */ }
Expand description
A stream for writing to a file on Android.
Implements std::io::Write
, so it can be used for writing.
As with std::fs::File
, wrap it with std::io::BufWriter
if buffering is needed.
After writing, call WritableStream::reflect
to apply changes.
§Inner
This is a wrapper around std::fs::File
.
In most cases, it points to the actual target file, but it may also refer to a temporary file.
For temporary files, calling WritableStream::reflect
applies the changes to the actual target.
Implementations§
Source§impl<R: Runtime> WritableStream<R>
impl<R: Runtime> WritableStream<R>
Sourcepub fn reflect(self) -> Result<()>
pub fn reflect(self) -> Result<()>
WritableStream
is a wrapper around std::fs::File
.
In most cases, it points to the actual target file, but it may also refer to a temporary file.
For actual target files, this function does nothing.
For temporary files, calling this function applies the changes to the actual target. This may take as long as the write operation or even longer. Note that if the file is located on cloud storage or similar, the function returns without waiting for the uploading to complete.
If not called explicitly, the changes are applied on drop, but no error is returned.
Sourcepub fn sync_all(&mut self) -> Result<()>
pub fn sync_all(&mut self) -> Result<()>
WritableStream
is a wrapper around std::fs::File
.
In most cases, it points to the actual target file, but it may also refer to a temporary file.
For actual target files, calls std::fs::File::sync_all
.
For temporary files, this function does nothing.
Sourcepub fn sync_data(&mut self) -> Result<()>
pub fn sync_data(&mut self) -> Result<()>
WritableStream
is a wrapper around std::fs::File
.
In most cases, it points to the actual target file, but it may also refer to a temporary file.
For actual target files, calls std::fs::File::sync_data
.
For temporary files, this function does nothing.
Trait Implementations§
Source§impl<R: Runtime> Drop for WritableStream<R>
impl<R: Runtime> Drop for WritableStream<R>
Source§impl<R: Runtime> Write for WritableStream<R>
impl<R: Runtime> Write for WritableStream<R>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Source§fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)