Package org.capnproto
Class Serialize
- java.lang.Object
-
- org.capnproto.Serialize
-
public final class Serialize extends Object
Serialization using the standard (unpacked) stream encoding: https://capnproto.org/encoding.html#serialization-over-a-stream
-
-
Constructor Summary
Constructors Constructor Description Serialize()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longcomputeSerializedSizeInWords(MessageBuilder message)static voidfillBuffer(ByteBuffer buffer, ReadableByteChannel bc)static MessageReaderread(ByteBuffer bb)static MessageReaderread(ByteBuffer bb, ReaderOptions options)Upon return, `bb.position()` will be at the end of the message.static MessageReaderread(ReadableByteChannel bc)static MessageReaderread(ReadableByteChannel bc, ReaderOptions options)static Optional<MessageReader>tryRead(ReadableByteChannel bc)Attempts to read a message from the provided BufferedInputStream with default options.static Optional<MessageReader>tryRead(ReadableByteChannel bc, ReaderOptions options)Attempts to read a message from the provided BufferedInputStream with the provided options.static voidwrite(WritableByteChannel outputChannel, MessageBuilder message)Serializes a MessageBuilder to a WritableByteChannel.static voidwrite(WritableByteChannel outputChannel, MessageReader message)Serializes a MessageReader to a WritableByteChannel.
-
-
-
Method Detail
-
fillBuffer
public static void fillBuffer(ByteBuffer buffer, ReadableByteChannel bc) throws IOException
- Throws:
IOException
-
tryRead
public static Optional<MessageReader> tryRead(ReadableByteChannel bc) throws IOException
Attempts to read a message from the provided BufferedInputStream with default options. Returns null if the input stream reached end-of-stream on first read.- Throws:
IOException
-
tryRead
public static Optional<MessageReader> tryRead(ReadableByteChannel bc, ReaderOptions options) throws IOException
Attempts to read a message from the provided BufferedInputStream with the provided options. Returns null if the input stream reached end-of-stream on first read.- Throws:
IOException
-
read
public static MessageReader read(ReadableByteChannel bc) throws IOException
- Throws:
IOException
-
read
public static MessageReader read(ReadableByteChannel bc, ReaderOptions options) throws IOException
- Throws:
IOException
-
read
public static MessageReader read(ByteBuffer bb) throws IOException
- Throws:
IOException
-
read
public static MessageReader read(ByteBuffer bb, ReaderOptions options) throws IOException
Upon return, `bb.position()` will be at the end of the message.- Throws:
IOException
-
computeSerializedSizeInWords
public static long computeSerializedSizeInWords(MessageBuilder message)
-
write
public static void write(WritableByteChannel outputChannel, MessageBuilder message) throws IOException
Serializes a MessageBuilder to a WritableByteChannel.- Throws:
IOException
-
write
public static void write(WritableByteChannel outputChannel, MessageReader message) throws IOException
Serializes a MessageReader to a WritableByteChannel.- Throws:
IOException
-
-