diff --git a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt index b5a32590..0f12c213 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt @@ -1,7 +1,10 @@ package hep.dataforge.io import hep.dataforge.meta.* -import kotlinx.io.* +import kotlinx.io.ArrayBinary +import kotlinx.io.Binary +import kotlinx.io.ExperimentalIoApi +import kotlinx.io.Output class EnvelopeBuilder { private val metaBuilder = MetaBuilder() @@ -26,9 +29,7 @@ class EnvelopeBuilder { */ @ExperimentalIoApi fun data(block: Output.() -> Unit) { - val bytes = buildBytes(builder = block) - data = bytes.toByteArray().asBinary() //save data to byte array so - bytes.close() + data = ArrayBinary.write(builder = block) } internal fun build() = SimpleEnvelope(metaBuilder.seal(), data) diff --git a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeParts.kt b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeParts.kt index 471ee3be..8e0b16de 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeParts.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeParts.kt @@ -21,7 +21,7 @@ object EnvelopeParts { val FORMAT_NAME_KEY = Envelope.ENVELOPE_NODE_KEY + MULTIPART_KEY + "format" val FORMAT_META_KEY = Envelope.ENVELOPE_NODE_KEY + MULTIPART_KEY + "meta" - const val MULTIPART_DATA_SEPARATOR = "#~PART~#\r\n" + const val MULTIPART_DATA_SEPARATOR = "\r\n#~PART~#\r\n" const val MULTIPART_DATA_TYPE = "envelope.multipart" } @@ -113,7 +113,7 @@ fun Envelope.parts(io: IOPlugin = Global.plugins.fetch(IOPlugin)): Sequence