Crates.io | prost-uuid |
lib.rs | prost-uuid |
version | 0.2.0 |
source | src |
created_at | 2023-05-22 13:55:16.241348 |
updated_at | 2023-05-24 16:14:44.121654 |
description | ProstUuid new-type wrapper around uuid::Uuid with prost::Message implemented for it. |
homepage | https://gitlab.com/oss47/prost-uuid |
repository | https://gitlab.com/oss47/prost-uuid |
max_upload_size | |
id | 870701 |
size | 5,689 |
ProstUuid new-type wrapper around uuid::Uuid with prost::Message implemented for it.
Create a protobuf file for uuid (will be provided out-of-the-box in future release):
syntax = "proto3";
package uuid;
message Uuid {
string uuid_str = 1;
}
and use it in your own protobuf:
message User {
uuid.Uuid id = 1;
string email = 2;
}
in Rust code you will be able to use ProstUuid
interchangably with uuid::Uuid
via different methods and dereferencing:
fn test_derive_more() {
let prost_uuid = ProstUuid::from(Uuid::nil());
let uuid = Uuid::from(prost_uuid);
assert_eq!(format!("{}", uuid), format!("{}", prost_uuid));
let new_prost_uuid = ProstUuid::new(uuid);
let mut mut_prost_uuid = new_prost_uuid;
let another_prost_uuid = new_prost_uuid;
function_expect_uuid(
new_prost_uuid.as_ref(),
mut_prost_uuid.as_mut(),
*another_prost_uuid,
);
}
fn function_expect_uuid(_uuid_ref: &Uuid, _uuid_mut_ref: &mut Uuid, _uuid: Uuid) {}