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> SyncWritableStream<R>
impl<R: Runtime> SyncWritableStream<R>
Sourcepub fn into_sync(self) -> SyncWritableStream<R> ⓘ
pub fn into_sync(self) -> SyncWritableStream<R> ⓘ
Converts to a WritableStream for synchronous processing.
Sourcepub fn into_async(self) -> AsyncWritableStream<R> ⓘ
pub fn into_async(self) -> AsyncWritableStream<R> ⓘ
Converts to a WritableStream for asynchronous processing.
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, and remove the temporary file. 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 same process is performed asynchronously on drop, and all errors is are ignored.
Sourcepub fn sync_all(&self) -> Result<()>
pub fn sync_all(&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(&self) -> Result<()>
pub fn sync_data(&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> Write for SyncWritableStream<R>
impl<R: Runtime> Write for SyncWritableStream<R>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
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 is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)