pub struct WriteableStream { /* private fields */ }Expand description
Loose wrapper implementation of a stream on top of the File System
Access API’s FileSystemWritableFileStream.
The page writes only asynchronously. write_async,
flush_async and close_async
are upstream’s WriteAsync, FlushAsync and DisposeAsync. The
synchronous Write the storage contracts hand out issues the same
writes without waiting for them (the browser cannot block): the script
stream queues them in order, and write and flush report a failure
that has already settled. Dropping the stream closes it, which commits
the file once the queued writes are done. Until that close settles, the
storage items wait before they open the same file or read its
properties, and a failed write or close is logged and reported by the
next opening of that file (see [settle_pending_closes]).
Implementations§
Source§impl WriteableStream
impl WriteableStream
pub fn can_read(&self) -> bool
pub fn can_seek(&self) -> bool
pub fn can_write(&self) -> bool
pub fn length(&self) -> u64
pub fn position(&self) -> u64
Sourcepub fn set_position(&mut self, position: u64) -> Result<()>
pub fn set_position(&mut self, position: u64) -> Result<()>
Moves the position to position.
Sourcepub fn set_length(&mut self, value: u64) -> Result<()>
pub fn set_length(&mut self, value: u64) -> Result<()>
Resizes the file to value bytes.
Sourcepub async fn write_async(&mut self, buffer: &[u8]) -> Result<()>
pub async fn write_async(&mut self, buffer: &[u8]) -> Result<()>
Writes buffer at the position; resolves once the page has written
it.
Sourcepub async fn flush_async(&mut self) -> Result<()>
pub async fn flush_async(&mut self) -> Result<()>
Resolves once every write, seek and truncation issued through the synchronous members has settled, with the first failure among them.
Sourcepub async fn close_async(self) -> Result<()>
pub async fn close_async(self) -> Result<()>
Closes the stream, which commits the written content to the file.
Trait Implementations§
Source§impl Drop for WriteableStream
impl Drop for WriteableStream
Source§impl Seek for WriteableStream
impl Seek for WriteableStream
Source§fn seek(&mut self, position: SeekFrom) -> Result<u64>
fn seek(&mut self, position: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)Source§impl Write for WriteableStream
impl Write for WriteableStream
Source§fn write(&mut self, buffer: &[u8]) -> Result<usize>
fn write(&mut self, buffer: &[u8]) -> Result<usize>
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)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Auto Trait Implementations§
impl !RefUnwindSafe for WriteableStream
impl !Send for WriteableStream
impl !Sync for WriteableStream
impl !UnwindSafe for WriteableStream
impl Freeze for WriteableStream
impl Unpin for WriteableStream
impl UnsafeUnpin for WriteableStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more