Writer

zio.blocks.streams.io.Writer
See theWriter companion object
abstract class Writer[-Elem]

The write-side dual of Reader: a producer pushes elements and observes when the channel is done. Used internally by channel-based implementations and available directly for push-based integration.

==Thread safety== Writer instances are ''not'' thread-safe unless otherwise documented. They are designed for single-threaded push-based production.

==Termination== A writer is closed by calling close (clean) or fail (with error). After close, write returns false. After fail, subclasses that override fail may cause write to throw the stored error; the default fail simply delegates to close. Both are idempotent; only the first call wins.

==Laws==

  • isClosed is monotone: once true it never returns false.
  • After isClosed: write returns false (clean close) or throws (error close, if the subclass implements error storage via fail).

Type parameters

Elem

Element type (contravariant).

Attributes

Companion
object
Source
Writer.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def close(): Unit

Closes the writer. After this call, write returns false and isClosed returns true. Idempotent.

Closes the writer. After this call, write returns false and isClosed returns true. Idempotent.

Attributes

Source
Writer.scala
def isClosed: Boolean

true once the writer is closed.

true once the writer is closed.

Attributes

Source
Writer.scala
def write(a: Elem): Boolean

Writes one element. Returns true on success, false if the writer is closed. Implementations backed by bounded buffers may block until space is available. Throws if the writer was closed with an error via fail.

Writes one element. Returns true on success, false if the writer is closed. Implementations backed by bounded buffers may block until space is available. Throws if the writer was closed with an error via fail.

Attributes

Source
Writer.scala

Concrete methods

def ++[Elem1 <: Elem](next: => Writer[Elem1]): Writer[Elem1]

Alias for concat.

Alias for concat.

Attributes

Source
Writer.scala
final def closeAsync(): encoding.Async[Unit]

Deferred, cancellable mirror of close.

Deferred, cancellable mirror of close.

Attributes

Source
Writer.scala
def concat[Elem1 <: Elem](next: => Writer[Elem1]): Writer[Elem1]

Returns a Writer that writes to this until it closes, then transparently switches to next. If this closes with an error, the error is propagated immediately without consulting next.

Returns a Writer that writes to this until it closes, then transparently switches to next. If this closes with an error, the error is propagated immediately without consulting next.

The dual of Reader.concat.

Attributes

Source
Writer.scala
def contramap[Elem2](g: Elem2 => Elem): Writer[Elem2]

Returns a Writer that transforms incoming elements with g before passing them to this writer. All other operations (isClosed, close, fail) delegate unchanged.

Returns a Writer that transforms incoming elements with g before passing them to this writer. All other operations (isClosed, close, fail) delegate unchanged.

Attributes

Source
Writer.scala
def fail(error: Throwable): Unit

Closes the writer with an error. After this call, isClosed returns true. Subclasses that override this method may cause write to throw error on subsequent calls; the default simply delegates to close. Close and fail are idempotent; only the first call wins.

Closes the writer with an error. After this call, isClosed returns true. Subclasses that override this method may cause write to throw error on subsequent calls; the default simply delegates to close. Close and fail are idempotent; only the first call wins.

Attributes

Source
Writer.scala
final def failAsync(error: Throwable): encoding.Async[Unit]

Deferred, cancellable mirror of fail.

Deferred, cancellable mirror of fail.

Attributes

Source
Writer.scala
final def isClosedAsync: encoding.Async[Boolean]

Deferred, cancellable mirror of isClosed.

Deferred, cancellable mirror of isClosed.

Attributes

Source
Writer.scala

The primitive type of elements in this writer, or AnyRef for reference types.

The primitive type of elements in this writer, or AnyRef for reference types.

Attributes

Source
Writer.scala
final def jvmTypeAsync: encoding.Async[JvmType]

Deferred, cancellable mirror of jvmType.

Deferred, cancellable mirror of jvmType.

Attributes

Source
Writer.scala
def writeAll[Elem1 <: Elem](chunk: Chunk[Elem1]): Chunk[Elem1]

Writes every element in chunk. Returns the suffix not delivered. If the writer is already closed, returns the entire chunk. Exceptions from individual writes propagate to the caller.

Writes every element in chunk. Returns the suffix not delivered. If the writer is already closed, returns the entire chunk. Exceptions from individual writes propagate to the caller.

Attributes

Source
Writer.scala
final def writeAllAsync[Elem1 <: Elem](chunk: Chunk[Elem1]): encoding.Async[Chunk[Elem1]]

Deferred, cancellable mirror of writeAll.

Deferred, cancellable mirror of writeAll.

Attributes

Source
Writer.scala
final def writeAsync(a: Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of write.

Deferred, cancellable mirror of write.

Attributes

Source
Writer.scala
def writeBoolean(value: Boolean)(implicit ev: Boolean <:< Elem): Boolean

Specialized Boolean write. Default delegates to generic write. Requires implicit evidence that Boolean is a subtype of Elem.

Specialized Boolean write. Default delegates to generic write. Requires implicit evidence that Boolean is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeBooleanAsync(value: Boolean)(implicit ev: Boolean <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeBoolean.

Deferred, cancellable mirror of writeBoolean.

Attributes

Source
Writer.scala
def writeByte(b: Byte)(implicit ev: Byte <:< Elem): Boolean

Blocking byte write. Equivalent to write(b.asInstanceOf[Elem]) but avoids boxing when Elem = Byte. Returns false if the writer is closed. Requires implicit evidence that Byte is a subtype of Elem.

Blocking byte write. Equivalent to write(b.asInstanceOf[Elem]) but avoids boxing when Elem = Byte. Returns false if the writer is closed. Requires implicit evidence that Byte is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeByteAsync(b: Byte)(implicit ev: Byte <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeByte.

Deferred, cancellable mirror of writeByte.

Attributes

Source
Writer.scala
def writeBytes(buf: Array[Byte], offset: Int, len: Int)(implicit ev: Byte <:< Elem): Int

Blocking bulk byte write. Calls writeByte for each byte in buf[offset, offset+len), stopping early if the channel closes. Returns the number of bytes successfully written, which may be less than len if the channel closes mid-way. Requires implicit evidence that Byte is a subtype of Elem.

Blocking bulk byte write. Calls writeByte for each byte in buf[offset, offset+len), stopping early if the channel closes. Returns the number of bytes successfully written, which may be less than len if the channel closes mid-way. Requires implicit evidence that Byte is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeBytesAsync(buf: Array[Byte], offset: Int, len: Int)(implicit ev: Byte <:< Elem): encoding.Async[Int]

Deferred, cancellable mirror of writeBytes.

Deferred, cancellable mirror of writeBytes.

Attributes

Source
Writer.scala
def writeChar(value: Char)(implicit ev: Char <:< Elem): Boolean

Specialized Char write. Default delegates to generic write. Requires implicit evidence that Char is a subtype of Elem.

Specialized Char write. Default delegates to generic write. Requires implicit evidence that Char is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeCharAsync(value: Char)(implicit ev: Char <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeChar.

Deferred, cancellable mirror of writeChar.

Attributes

Source
Writer.scala
def writeDouble(value: Double)(implicit ev: Double <:< Elem): Boolean

Specialized Double write. Default delegates to generic write. Requires implicit evidence that Double is a subtype of Elem.

Specialized Double write. Default delegates to generic write. Requires implicit evidence that Double is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeDoubleAsync(value: Double)(implicit ev: Double <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeDouble.

Deferred, cancellable mirror of writeDouble.

Attributes

Source
Writer.scala
def writeFloat(value: Float)(implicit ev: Float <:< Elem): Boolean

Specialized Float write. Default delegates to generic write. Requires implicit evidence that Float is a subtype of Elem.

Specialized Float write. Default delegates to generic write. Requires implicit evidence that Float is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeFloatAsync(value: Float)(implicit ev: Float <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeFloat.

Deferred, cancellable mirror of writeFloat.

Attributes

Source
Writer.scala
def writeInt(value: Int)(implicit ev: Int <:< Elem): Boolean

Specialized Int write. Default delegates to generic write. Requires implicit evidence that Int is a subtype of Elem.

Specialized Int write. Default delegates to generic write. Requires implicit evidence that Int is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeIntAsync(value: Int)(implicit ev: Int <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeInt.

Deferred, cancellable mirror of writeInt.

Attributes

Source
Writer.scala
def writeLong(value: Long)(implicit ev: Long <:< Elem): Boolean

Specialized Long write. Default delegates to generic write. Requires implicit evidence that Long is a subtype of Elem.

Specialized Long write. Default delegates to generic write. Requires implicit evidence that Long is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeLongAsync(value: Long)(implicit ev: Long <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeLong.

Deferred, cancellable mirror of writeLong.

Attributes

Source
Writer.scala
def writeShort(value: Short)(implicit ev: Short <:< Elem): Boolean

Specialized Short write. Default delegates to generic write. Requires implicit evidence that Short is a subtype of Elem.

Specialized Short write. Default delegates to generic write. Requires implicit evidence that Short is a subtype of Elem.

Attributes

Source
Writer.scala
final def writeShortAsync(value: Short)(implicit ev: Short <:< Elem): encoding.Async[Boolean]

Deferred, cancellable mirror of writeShort.

Deferred, cancellable mirror of writeShort.

Attributes

Source
Writer.scala
def writeable(): Boolean

Returns true if the next write would accept a value without blocking (space is available and the writer is not closed). Default implementation returns !isClosed. Subclasses backed by bounded buffers should override for accuracy.

Returns true if the next write would accept a value without blocking (space is available and the writer is not closed). Default implementation returns !isClosed. Subclasses backed by bounded buffers should override for accuracy.

Attributes

Source
Writer.scala
final def writeableAsync(): encoding.Async[Boolean]

Deferred, cancellable mirror of writeable.

Deferred, cancellable mirror of writeable.

Attributes

Source
Writer.scala