diff --git a/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSink.kt b/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSink.kt index dbf25b234e..ab24fd5090 100644 --- a/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSink.kt +++ b/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSink.kt @@ -16,6 +16,7 @@ package com.squareup.wire import kotlin.Throws +import okio.Closeable import okio.IOException /** @@ -39,8 +40,11 @@ import okio.IOException * You should ensure that such backpressure propagates to the originator of outbound messages. * * Instances of this interface are not safe for concurrent use. + * + * Closing a sink will terminate the stream and release its resources. If this has not been canceled + * this signals a normal completion of the stream. */ -expect interface MessageSink { +interface MessageSink : Closeable { /** * Encode [message] to bytes and enqueue the bytes for delivery, waiting if necessary until the * delivery channel has capacity for the encoded message. @@ -60,11 +64,4 @@ expect interface MessageSink { */ @Throws(IOException::class) fun cancel() - - /** - * Terminate the stream and release its resources. If this has not been canceled this signals a - * normal completion of the stream. - */ - @Throws(IOException::class) - fun close() } diff --git a/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSource.kt b/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSource.kt index 5a7c890034..0c6b9b476a 100644 --- a/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSource.kt +++ b/wire-runtime/src/commonMain/kotlin/com/squareup/wire/MessageSource.kt @@ -16,6 +16,7 @@ package com.squareup.wire import kotlin.Throws +import okio.Closeable import okio.IOException /** @@ -35,7 +36,7 @@ import okio.IOException * * Instances of this interface are not safe for concurrent use. */ -expect interface MessageSource { +interface MessageSource : Closeable { /** * Read the next length-prefixed message on the stream and return it. Returns null if there are * no further messages on this stream. @@ -45,7 +46,4 @@ expect interface MessageSource { */ @Throws(IOException::class) fun read(): T? - - @Throws(IOException::class) - fun close() } diff --git a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/EnumAdapter.kt b/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/EnumAdapter.kt index 9e8ee14dbc..16f2210008 100644 --- a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/EnumAdapter.kt +++ b/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/EnumAdapter.kt @@ -16,8 +16,8 @@ package com.squareup.wire import com.squareup.wire.internal.identityOrNull -import java.io.IOException import kotlin.reflect.KClass +import okio.IOException /** * An abstract [ProtoAdapter] that converts values of an enum to and from integers. diff --git a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/MessageSink.kt b/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/MessageSink.kt deleted file mode 100644 index 7a69974b70..0000000000 --- a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/MessageSink.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2019 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -import java.io.Closeable -import okio.IOException - -actual interface MessageSink : Closeable { - @Throws(IOException::class) - actual fun write(message: T) - - @Throws(IOException::class) - actual fun cancel() -} diff --git a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/MessageSource.kt b/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/MessageSource.kt deleted file mode 100644 index 481ccf20a6..0000000000 --- a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/MessageSource.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2019 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -import java.io.Closeable -import okio.IOException - -actual interface MessageSource : Closeable { - @Throws(IOException::class) - actual fun read(): T? -} diff --git a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/ProtoAdapter.kt b/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/ProtoAdapter.kt index 712ace9c59..e45fb86cc3 100644 --- a/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/ProtoAdapter.kt +++ b/wire-runtime/src/jvmMain/kotlin/com/squareup/wire/ProtoAdapter.kt @@ -18,13 +18,13 @@ package com.squareup.wire import com.squareup.wire.internal.createRuntimeMessageAdapter -import java.io.IOException import java.io.InputStream import java.io.OutputStream import kotlin.reflect.KClass import okio.BufferedSink import okio.BufferedSource import okio.ByteString +import okio.IOException import okio.buffer import okio.sink import okio.source diff --git a/wire-runtime/src/nonJvmMain/kotlin/com/squareup/wire/MessageSink.kt b/wire-runtime/src/nonJvmMain/kotlin/com/squareup/wire/MessageSink.kt deleted file mode 100644 index 018ab1a327..0000000000 --- a/wire-runtime/src/nonJvmMain/kotlin/com/squareup/wire/MessageSink.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2019 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -import kotlin.Throws -import okio.IOException - -actual interface MessageSink { - @Throws(IOException::class) - actual fun write(message: T) - - @Throws(IOException::class) - actual fun cancel() - - @Throws(IOException::class) - actual fun close() -} diff --git a/wire-runtime/src/nonJvmMain/kotlin/com/squareup/wire/MessageSource.kt b/wire-runtime/src/nonJvmMain/kotlin/com/squareup/wire/MessageSource.kt deleted file mode 100644 index 5fe38ce1ee..0000000000 --- a/wire-runtime/src/nonJvmMain/kotlin/com/squareup/wire/MessageSource.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2019 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -import kotlin.Throws -import okio.IOException - -actual interface MessageSource { - @Throws(IOException::class) - actual fun read(): T? - - @Throws(IOException::class) - actual fun close() -}