package com.github.shadowsocks.http

data class ApiResult<T>(
    val code: Int,
    val data: T? = null,
    val error: String? = null,
) {
    constructor(err: ApiError) : this(err.code, null, err.msg)

    fun isSuccessful(): Boolean = code == 200 && error == null

    fun unwrapData(): T = data!!
}


enum class ApiError(val code: Int, val msg: String) {
    NetworkError(901, "网络错误")
}