Deprecate ExternalImage constructors

This commit is contained in:
Him188 2020-04-29 19:39:41 +08:00
parent 9ed1025e30
commit 644f0f175b
2 changed files with 6 additions and 0 deletions

View File

@ -39,23 +39,27 @@ class ExternalImage private constructor(
val input: Any, // Input from kotlinx.io, InputStream from kotlinx.io MPP, ByteReadChannel from ktor
val inputSize: Long // dont be greater than Int.MAX
) {
@Deprecated("changing soon in 1.0.0", level = DeprecationLevel.ERROR)
constructor(
md5: ByteArray,
input: ByteReadChannel,
inputSize: Long // dont be greater than Int.MAX
) : this(md5, input as Any, inputSize)
@Deprecated("changing soon in 1.0.0", level = DeprecationLevel.ERROR)
constructor(
md5: ByteArray,
input: Input,
inputSize: Long // dont be greater than Int.MAX
) : this(md5, input as Any, inputSize)
@Deprecated("changing soon in 1.0.0", level = DeprecationLevel.ERROR)
constructor(
md5: ByteArray,
input: ByteReadPacket
) : this(md5, input as Any, input.remaining)
@Deprecated("changing soon in 1.0.0", level = DeprecationLevel.ERROR)
@OptIn(InternalSerializationApi::class)
constructor(
md5: ByteArray,

View File

@ -62,6 +62,7 @@ fun BufferedImage.toExternalImage(formatName: String = "png"): ExternalImage {
})
}
@Suppress("DEPRECATION_ERROR")
return ExternalImage(digest.digest(), file.inputStream())
}
@ -73,6 +74,7 @@ suspend inline fun BufferedImage.suspendToExternalImage(): ExternalImage = withC
@OptIn(MiraiInternalAPI::class)
@Throws(IOException::class)
fun File.toExternalImage(): ExternalImage {
@Suppress("DEPRECATION_ERROR")
return ExternalImage(
md5 = this.inputStream().md5(), // dont change
input = this.inputStream()