package nio
ZIO-NIO, the API for using Java's NIO API in ZIO programs.
- Alphabetic
- By Inheritance
- nio
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
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
Chunk
s 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 viaBuffer.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
Chunk
s. 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 anyjava.lang.CharSequence
.Views
While
ByteBuffer
s are created via allocation or wrapping, the other buffer types are more commonly constructed as a view over aByteBuffer
. 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()
-
class
ByteBuffer extends Buffer[Byte]
A mutable buffer of bytes.
-
final
class
CharBuffer extends Buffer[Char]
A mutable buffer of characters.
-
final
class
DoubleBuffer extends Buffer[Double]
A mutable buffer of doubles.
- implicit final class EffectOps[-R, +E, +A] extends AnyVal
-
final
class
FloatBuffer extends Buffer[Float]
A mutable buffer of floats.
-
trait
IOCloseable extends AnyRef
A resource with an effect to close or release the resource.
-
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.
-
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.
-
final
class
IntBuffer extends Buffer[Int]
A mutable buffer of ints.
- final class InterfaceAddress extends AnyRef
-
final
class
LongBuffer extends Buffer[Long]
A mutable buffer of longs.
-
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
- class NetworkInterface extends AnyRef
-
final
class
ShortBuffer extends Buffer[Short]
A mutable buffer of shorts.
-
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
- object Buffer
- object InetAddress
- object InetSocketAddress
- object NetworkInterface
- object SocketAddress