Packages

p

zio

nio

package nio

ZIO-NIO, the API for using Java's NIO API in ZIO programs.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. nio
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package channels
  2. package charset
  3. package file

Type Members

  1. abstract class Buffer[A] extends AnyRef

    Mutable buffer of value elements.

    Mutable buffer of value elements.

    This wraps one of the Java NIO buffer classes. Most of the Java documentation is applicable to this class.

    Buffer instances are in no way synchronized and are typically used from a single fiber. Extract immutable Chunks to pass values to other fibers or via streams.

    Construction

    There is a concrete buffer subclass for each primitive type. There are three ways to create a buffer:

    Allocation

    Simply allocates a new buffer on the heap of a certain size, for example Buffer.byte(100), Buffer.char(200).

    For ByteBuffer there is the special case of direct buffers, which can be constructed via Buffer.byteDirect. See the Java docs for details of the advantages and disadvantages of direct byte buffers.

    Wrapping

    Buffers can wrap existing Java buffers, or ZIO Chunks. Care must be taken when wrapping Java buffers that the wrapped buffer is not subsequently modified; these objects are typically wrapped to provide efficient interoperability with Java APIs.

    A CharBuffer can also wrap any java.lang.CharSequence.

    Views

    While ByteBuffers are created via allocation or wrapping, the other buffer types are more commonly constructed as a view over a ByteBuffer. Each numeric buffer class supports either big-endian or little-endian byte order as required.

    View buffers are constructed via the various asXXX methods on the zio.nio.ByteBuffer class, for example:

    val ints(implicit trace: Trace): UIO[IntBuffer] = bytes.asIntBuffer

    Changes to made via view buffers are reflected in the original ByteBuffer and vice-versa.

    Differences from Java

    The Java API supports "invocation chaining", which does not work with effect values. The Java example:

    b.flip().position(23).limit(42)

    is typically written:

    for {
      _ <- b.flip
      _ <- b.position(23)
      _ <- b.limit(42)
    } yield ()

    or in cases like this when the intermediate values aren't used:

    b.flip *> b.position(23) *> b.limit(42)
    Annotations
    @specialized()
  2. class ByteBuffer extends Buffer[Byte]

    A mutable buffer of bytes.

  3. final class CharBuffer extends Buffer[Char]

    A mutable buffer of characters.

  4. final class DoubleBuffer extends Buffer[Double]

    A mutable buffer of doubles.

  5. implicit final class EffectOps[-R, +E, +A] extends AnyVal
  6. final class FloatBuffer extends Buffer[Float]

    A mutable buffer of floats.

  7. trait IOCloseable extends AnyRef

    A resource with an effect to close or release the resource.

  8. final class InetAddress extends AnyRef

    Representation of an Internet Protocol (IP) address.

    Representation of an Internet Protocol (IP) address.

    Will be either a 32-bit IPv4 address or a 128-bit IPv6 address.

  9. final class InetSocketAddress extends SocketAddress

    Representation of an IP Socket Address (IP address + port number).

    Representation of an IP Socket Address (IP address + port number).

    It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname. If resolution fails then the address is said to be unresolved but can still be used on some circumstances like connecting through a proxy. However, note that network channels generally do not accept unresolved socket addresses.

    This class provides an immutable object used by sockets for binding, connecting, or as returned values.

    The wildcard is a special local IP address. It usually means "any" and can only be used for bind operations.

  10. final class IntBuffer extends Buffer[Int]

    A mutable buffer of ints.

  11. final class InterfaceAddress extends AnyRef
  12. final class LongBuffer extends Buffer[Long]

    A mutable buffer of longs.

  13. final class MappedByteBuffer extends ByteBuffer

    A direct byte buffer whose content is a memory-mapped region of a file.

    A direct byte buffer whose content is a memory-mapped region of a file. Mapped byte buffers are created by the FileChannel#map method.

    See also

    zio.nio.channels.FileChannel#map

  14. class NetworkInterface extends AnyRef
  15. final class ShortBuffer extends Buffer[Short]

    A mutable buffer of shorts.

  16. sealed class SocketAddress extends AnyRef

    Representation of a socket address without a specific protocol.

    Representation of a socket address without a specific protocol.

    The concrete subclass InetSocketAddress is used in practice.

Value Members

  1. object Buffer
  2. object InetAddress
  3. object InetSocketAddress
  4. object NetworkInterface
  5. object SocketAddress
  6. object ZStreamHelper

    A mutable buffer of shorts.

Inherited from AnyRef

Inherited from Any

Ungrouped