use crate::proto::Uuid as ProtoUuid;
pub trait ProtoUuidExt {
fn to_uuid(&self) -> Result<uuid::Uuid, uuid::Error>;
fn to_hex(&self) -> String;
}
impl ProtoUuidExt for ProtoUuid {
fn to_uuid(&self) -> Result<uuid::Uuid, uuid::Error> {
uuid::Uuid::from_slice(&self.value)
}
fn to_hex(&self) -> String {
hex::encode(&self.value)
}
}
pub trait UuidExt {
fn to_proto_uuid(&self) -> ProtoUuid;
}
impl UuidExt for uuid::Uuid {
fn to_proto_uuid(&self) -> ProtoUuid {
ProtoUuid {
value: self.as_bytes().to_vec(),
}
}
}