[][src]Struct wasm_streams::writable::WritableStreamDefaultWriter

pub struct WritableStreamDefaultWriter<'stream> { /* fields omitted */ }

A WritableStreamDefaultWriter that can be used to write chunks to a WritableStream.

This is returned by the get_writer method.

When the writer is dropped, it automatically releases its lock.

Implementations

impl<'stream> WritableStreamDefaultWriter<'stream>[src]

pub fn as_raw(&self) -> &WritableStreamDefaultWriter[src]

Acquires a reference to the underlying JavaScript writer.

pub async fn closed<'_>(&'_ self) -> Result<(), JsValue>[src]

Waits for the stream to become closed.

This returns an error if the stream ever errors, or if the writer's lock is released before the stream finishes closing.

pub fn desired_size(&self) -> Option<f64>[src]

Returns the desired size to fill the stream's internal queue.

  • It can be negative, if the queue is over-full. A producer can use this information to determine the right amount of data to write.
  • It will be None if the stream cannot be successfully written to (due to either being errored, or having an abort queued up).
  • It will return zero if the stream is closed.

pub async fn ready<'_>(&'_ self) -> Result<(), JsValue>[src]

Waits until the desired size to fill the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure.

Once the desired size to fill the stream's internal queue dips back to zero or below, this will return a new future that stays pending until the next transition.

This returns an error if the stream ever errors, or if the writer's lock is released before the stream finishes closing.

pub async fn abort<'_>(&'_ mut self) -> Result<(), JsValue>[src]

Aborts the stream, signaling that the producer can no longer successfully write to the stream.

Equivalent to WritableStream.abort.

pub async fn abort_with_reason<'_, '_>(
    &'_ mut self,
    reason: &'_ JsValue
) -> Result<(), JsValue>
[src]

Aborts the stream with the given reason, signaling that the producer can no longer successfully write to the stream.

Equivalent to WritableStream.abort_with_reason.

pub async fn write<'_>(&'_ mut self, chunk: JsValue) -> Result<(), JsValue>[src]

Writes the given chunk to the writable stream, by waiting until any previous writes have finished successfully, and then sending the chunk to the underlying sink's write() method.

This returns Ok(()) upon a successful write, or Err(error) if the write fails or stream becomes errored before the writing process is initiated.

Note that what "success" means is up to the underlying sink; it might indicate simply that the chunk has been accepted, and not necessarily that it is safely saved to its ultimate destination.

pub async fn close<'_>(&'_ mut self) -> Result<(), JsValue>[src]

Closes the stream.

The underlying sink will finish processing any previously-written chunks, before invoking its close behavior. During this time any further attempts to write will fail (without erroring the stream).

This returns Ok(()) if all remaining chunks are successfully written and the stream successfully closes, or Err(error) if an error is encountered during this process.

pub fn into_sink(self) -> IntoSink<'stream>[src]

Converts this WritableStreamDefaultWriter into a Sink.

This is similar to WritableStream.into_sink, except that after the returned Sink is dropped, the original WritableStream is still usable. This allows writing only a few chunks through the Sink, while still allowing another writer to write more chunks later on.

Trait Implementations

impl<'stream> Debug for WritableStreamDefaultWriter<'stream>[src]

impl<'_> Drop for WritableStreamDefaultWriter<'_>[src]

Auto Trait Implementations

impl<'stream> RefUnwindSafe for WritableStreamDefaultWriter<'stream>

impl<'stream> !Send for WritableStreamDefaultWriter<'stream>

impl<'stream> !Sync for WritableStreamDefaultWriter<'stream>

impl<'stream> Unpin for WritableStreamDefaultWriter<'stream>

impl<'stream> !UnwindSafe for WritableStreamDefaultWriter<'stream>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.