MessageSink

trait MessageSink extends AutoCloseable with Flushable

Provides a buffered output stream that writes sequence of WriteBuffer instances.

A Sink implementation has total control of the buffer memory so that it can reuse buffer memory, use buffer pools, or use memory-mapped files.

trait Flushable
trait AutoCloseable
class Object
trait Matchable
class Any

Value members

Abstract methods

@throws(scala.throws.$lessinit$greater$default$1[java.io.IOException])
def add(buffer: Array[Byte], offset: Int, length: Int): Unit

Writes an external payload data.

Writes an external payload data.

Unlike int, int) method, the buffer is given - this BufferSink implementation gets ownership of the buffer and may modify contents of the buffer. Contents of this buffer won't be modified by the caller.

Value parameters:
buffer

the data to add

length

the number of bytes to add

offset

the start offset in the data

@throws(scala.throws.$lessinit$greater$default$1[java.io.IOException])
def next(minimumSize: Int): WriteBuffer

Allocates the next buffer for writing MessagePack data.

Allocates the next buffer for writing MessagePack data.

This method returns an WriteBuffer instance that has specified size of capacity at least.

When this method is called twice, the previously returned buffer is no longer used. This method may be called twice without call of writeBuffer in between. In this case, the buffer should be discarded without flushing it to the output.

Value parameters:
minimumSize

the minimum required buffer size to allocate

Returns:

a Buffer instance with at least minimumSize bytes of capacity

@throws(scala.throws.$lessinit$greater$default$1[java.io.IOException])
def write(buffer: Array[Byte], offset: Int, length: Int): Unit

Writes an external payload data. This method should follow semantics of OutputStream.

Writes an external payload data. This method should follow semantics of OutputStream.

Value parameters:
buffer

the data to write

length

the number of bytes to write

offset

the start offset in the data

@throws(scala.throws.$lessinit$greater$default$1[java.io.IOException])
def writeBuffer(length: Int): Unit

Writes the previously allocated buffer(s).

Writes the previously allocated buffer(s).

This method should write the buffer previously returned from next method until specified number of bytes. Once the entire buffer contents is totally written to the sink, the buffer should not be used because a BufferSink implementation might reuse the buffer.

This method is not always called for each next call. In this case, the buffer should be discarded without flushing it to the output when the next next is called.

Value parameters:
length

the number of bytes to write

Inherited methods

@throws(java.lang.Exception)
def close(): Unit
Inherited from:
AutoCloseable
@throws(java.io.IOException)
def flush(): Unit
Inherited from:
Flushable