pub struct WritableStreamDefaultWriter<'stream> { /* private fields */ }
Expand description

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

Acquires a reference to the underlying JavaScript writer.

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.

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.

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.

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

Equivalent to WritableStream.abort.

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.

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.

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.

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.

Converts this WritableStreamDefaultWriter into an AsyncWrite.

The writable stream must accept Uint8Array chunks.

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

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.