pub struct PgUuid(/* private fields */);Expand description
A PostgreSQL uuid, ordered as uuid_cmp orders it, byte by byte, and printed as uuid_out
prints it, in lowercase 8-4-4-4-12 form.
use sql_values::postgres::PgUuid;
let uuid = |text| PgUuid::parse(text).unwrap();
let canonical = "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11";
for spelling in [
"A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11",
"{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}",
"a0eebc999c0b4ef8bb6d6bb9bd380a11",
"a0ee-bc99-9c0b4ef8-bb6d-6bb9-bd38-0a11",
] {
assert_eq!(uuid(spelling).to_string(), canonical);
}
for refused in [
" a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"a0eebc9-99c0b-4ef8-bb6d-6bb9bd380a11",
"a0eebc99--9c0b-4ef8-bb6d-6bb9bd380a11",
"{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11-",
] {
assert!(PgUuid::parse(refused).is_err());
}
let bytes = [
0xa0, 0xee, 0xbc, 0x99, 0x9c, 0x0b, 0x4e, 0xf8, 0xbb, 0x6d, 0x6b, 0xb9, 0xbd, 0x38, 0x0a, 0x11,
];
assert_eq!(PgUuid::from(bytes), uuid(canonical));
assert_eq!(uuid(canonical).as_bytes(), &bytes);
let low = uuid("00000000-0000-0000-0000-0000000000ff");
assert!(low < uuid("01000000-0000-0000-0000-000000000000"));Implementations§
Trait Implementations§
impl Copy for PgUuid
impl Eq for PgUuid
Source§impl Ord for PgUuid
impl Ord for PgUuid
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for PgUuid
impl PartialOrd for PgUuid
impl StructuralPartialEq for PgUuid
Auto Trait Implementations§
impl Forget for PgUuid
impl Freeze for PgUuid
impl Move for PgUuid
impl RefUnwindSafe for PgUuid
impl Send for PgUuid
impl Sync for PgUuid
impl Unpin for PgUuid
impl UnsafeUnpin for PgUuid
impl UnwindSafe for PgUuid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more