///|
struct PgUUID {
uuid : UUID
} derive(Show)
///|
pub impl @debug.Debug for PgUUID with fn to_repr(self : PgUUID) -> Repr {
Repr::ctor("UUID", [(None, Repr::string(self.uuid.to_string()))])
}
///|
pub fn PgUUID::of_uuid(uuid : UUID) -> PgUUID {
PgUUID::{ uuid, }
}
///|
pub fn PgUUID::to_uuid(self : Self) -> UUID {
self.uuid
}
///|
pub fn PgUUID::to_string(self : Self) -> Unit {
println("PgUUID - uuid:\{self.uuid}")
}
///|
pub impl @pgclient.ToSql for PgUUID with fn format(_, _) {
@pgclient.WireFormat::Binary
}
///|
pub impl @pgclient.ToSql for PgUUID with fn accepts(_, type_) {
type_.oid == @pgclient.Type::uuid().oid
}
///|
pub impl @pgclient.ToSql for PgUUID with fn moonbit_type_name(_) {
"PgUUID"
}
///|
pub impl @pgclient.ToSql for PgUUID with fn to_sql(self, _, buf) {
buf.write_bytes(self.uuid.to_bytes())
No
}
///|
pub impl @pgclient.FromSql for PgUUID with fn accepts(type_) {
type_.oid == @pgclient.Type::uuid().oid
}
///|
pub impl @pgclient.FromSql for PgUUID with fn moonbit_type_name() {
"PgUUID"
}
///|
pub impl @pgclient.FromSql for PgUUID with fn from_sql(_, format, raw) {
match format {
@pgclient.WireFormat::Binary => {
let uuid = @uuid.from_bytes(raw.to_owned())
return PgUUID::of_uuid(uuid)
}
_ =>
raise UnexpectedNullorInvalid("PgUUID -> @uuid.UUID. Raw bytes - \{raw}")
}
}