---
source: boltffi_bindgen/src/render/kotlin/templates.rs
expression: template.render().unwrap()
---

data class UserProfile(
    val name: String,
    val bio: String? = null
) {
    companion object {
        fun decode(reader: WireReader): UserProfile = UserProfile(
            reader.readString(),
            reader.readOption { it.readString() }
        )
    }
    fun wireEncodedSize(): Int =
        reader.sizeString(name) +
        reader.sizeOption(bio) { it.sizeString(it) }

    fun wireEncodeTo(wire: WireWriter) {
        wire.writeString(name)
        wire.writeOption(bio) { w, v -> w.writeString(v) }
    }
}
