2014-01-15 22:43:19 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "kj/io.h"
|
|
|
|
#include "capnp/dynamic.h"
|
|
|
|
#include "capnp/serialize-packed.h"
|
|
|
|
|
2014-02-24 14:06:28 -08:00
|
|
|
kj::Array< ::capnp::byte> messageToPackedBytes(capnp::MessageBuilder & message, size_t wordCount)
|
2014-01-15 22:43:19 -08:00
|
|
|
{
|
|
|
|
|
2014-02-24 14:06:28 -08:00
|
|
|
kj::Array<capnp::byte> result = kj::heapArray<capnp::byte>(wordCount * 8);
|
2014-01-15 22:43:19 -08:00
|
|
|
kj::ArrayOutputStream out(result.asPtr());
|
|
|
|
capnp::writePackedMessage(out, message);
|
|
|
|
return heapArray(out.getArray()); // TODO: make this non-copying somehow
|
2023-02-21 08:31:12 +02:00
|
|
|
}
|