2021-01-26 19:45:18 +01:00
|
|
|
use std::convert::TryInto;
|
|
|
|
use uuid::Bytes;
|
|
|
|
use crate::print_error;
|
|
|
|
|
|
|
|
pub fn to_uuid_bytes(bytes: &[u8]) -> Option<Bytes> {
|
|
|
|
match bytes.try_into() {
|
|
|
|
Ok(uuid) => Some(uuid),
|
|
|
|
Err(e) => {
|
|
|
|
print_error!(e);
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! print_error {
|
|
|
|
($arg:tt) => ({
|
2021-05-27 20:15:03 +02:00
|
|
|
log::error!("[{}:{}] {}", file!(), line!(), $arg);
|
2021-01-26 19:45:18 +01:00
|
|
|
});
|
|
|
|
($($arg:tt)*) => ({
|
2021-05-27 20:15:03 +02:00
|
|
|
log::error!("[{}:{}] {}", file!(), line!(), format_args!($($arg)*));
|
2021-01-26 19:45:18 +01:00
|
|
|
})
|
|
|
|
}
|