mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 20:55:03 +01:00
some cleanup
This commit is contained in:
parent
8532d454c3
commit
6d944e1265
12 changed files with 190 additions and 151 deletions
32
amqp_core/src/macros.rs
Normal file
32
amqp_core/src/macros.rs
Normal 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())
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue