Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEVICE_INFO_LATEST_VERSION #2758

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions mirai-core-api/src/commonMain/kotlin/utils/DeviceInfoManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import kotlin.jvm.JvmInline
import kotlin.jvm.JvmName

internal object DeviceInfoManager {

/**
* @since 2.16
*/
const val DEVICE_INFO_LATEST_VERSION = 3

sealed interface Info {
fun toDeviceInfo(): DeviceInfo
}
Expand Down Expand Up @@ -306,14 +312,14 @@ internal object DeviceInfoManager {
fun serialize(info: DeviceInfo, format: Json = this.format): String {
return format.encodeToString(
Wrapper.serializer(V3.serializer()),
Wrapper(3, info.toCurrentInfo())
Wrapper(DEVICE_INFO_LATEST_VERSION, info.toCurrentInfo())
)
}

fun toJsonElement(info: DeviceInfo, format: Json = this.format): JsonElement {
return format.encodeToJsonElement(
Wrapper.serializer(V3.serializer()),
Wrapper(3, info.toCurrentInfo())
Wrapper(DEVICE_INFO_LATEST_VERSION, info.toCurrentInfo())
)
}
}
}
Loading