some cleanup

This commit is contained in:
nora 2022-02-26 22:26:35 +01:00
parent 8532d454c3
commit 6d944e1265
12 changed files with 190 additions and 151 deletions

32
amqp_core/src/macros.rs Normal file
View file

@ -0,0 +1,32 @@
#[macro_export]
macro_rules! newtype_id {
($vis:vis $name:ident) => {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
$vis struct $name(::uuid::Uuid);
impl $name {
pub fn random() -> Self {
::rand::random()
}
}
impl ::std::fmt::Display for $name {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
impl ::rand::prelude::Distribution<$name> for ::rand::distributions::Standard {
fn sample<R: ::rand::Rng + ?Sized>(&self, rng: &mut R) -> $name {
$name(::uuid::Uuid::from_bytes(rng.gen()))
}
}
};
}
#[macro_export]
macro_rules! amqp_todo {
() => {
return Err(::amqp_core::error::ConException::NotImplemented.into())
};
}