scsys_core/id/traits/
id.rs

1pub trait RawIdentifier: Send + Sync + core::fmt::Debug + core::fmt::Display {
2    private!();
3}
4
5pub trait StdId: RawIdentifier {
6    /// Returns the raw identifier as a byte slice.
7    fn as_bytes(&self) -> &[u8];
8}
9
10/*
11 ************* Implementations *************
12*/
13#[cfg(feature = "alloc")]
14use alloc::string::String;
15
16macro_rules! impl_raw_id {
17    (@impl $t:ty) => {
18        impl RawIdentifier for $t {
19            seal!();
20        }
21    };
22    ($($t:ty),* $(,)?) => {
23        $(
24            impl_raw_id!(@impl $t);
25        )*
26    };
27}
28
29impl_raw_id! {
30    u8, u16, u32, u64, u128, usize,
31    i8, i16, i32, i64, i128, isize,
32    f32, f64, bool, char, str,
33}
34
35#[cfg(feature = "alloc")]
36impl_raw_id! {
37    String
38}