We’re using `wire` to generate Kotlin classes fro...
# squarelibraries
y
We’re using
wire
to generate Kotlin classes from proto in our KMP project. We got this construct to pass in Uuid’s:
Copy code
message UuidValue {
  string value = 1;
}
Is there a way to parse this construct to
kotlin.uuid.Uuid
(or similar)?. Mainly to prevent saving non-valid uuid’s. I saw the option to pass in a
schemaHandlerFactoryClass
, but adapting the default Kotlin Proto Parser might not be straightforward (maybe not recommended?)
b
There's no way right now to do so. With some plumberies, you could write a specific schema handler only for this type and leave the rest to Wire
I'm actually not sure it would work but I'm thinking you could do something like
Copy code
wire {
  custom {
    // This one would only generate the message for Uuid and claim it so that the other targets don't generate it
  }
  kotlin {
    // Generates the rest. Not sure how it would know to use the right class when a field is of type `UuidValue`
  }
}
y
got it, thanks. I’ll have a look If I can get something to work
👍 1
j
It would be more efficient to encode a UUID as two 64-bit uints
The string form is a human-readable version of that 128-bit number, but you should not store or transfer a UUID in that form
y
good input, thanks!