Skip to main content

rasn_its/
lib.rs

1#![cfg_attr(not(test), no_std)]
2extern crate alloc;
3
4/// ASN.1 definitions for ETSI TS 103 097
5pub mod ts103097;
6
7/// ASN.1 definitions for IEEE 1609.2
8pub mod ieee1609dot2;
9
10/// A macro to implement `From` and `Deref` for a delegate type pair.
11/// This is not suitable for newtypes with inner constraints.
12#[macro_export]
13macro_rules! delegate {
14    ($from_type:ty, $to_type:ty) => {
15        impl From<$from_type> for $to_type {
16            fn from(item: $from_type) -> Self {
17                Self(item)
18            }
19        }
20        impl From<$to_type> for $from_type {
21            fn from(item: $to_type) -> Self {
22                item.0
23            }
24        }
25        impl core::ops::Deref for $to_type {
26            type Target = $from_type;
27            fn deref(&self) -> &Self::Target {
28                &self.0
29            }
30        }
31        impl core::ops::DerefMut for $to_type {
32            fn deref_mut(&mut self) -> &mut Self::Target {
33                &mut self.0
34            }
35        }
36    };
37}