macros: add opaque macro
This commit is contained in:
parent
0a5b00f269
commit
9880f78ec4
16 changed files with 60 additions and 115 deletions
|
|
@ -1,35 +0,0 @@
|
|||
use {
|
||||
crate::utils::opaque::{OPAQUE_LEN, Opaque, OpaqueError, opaque},
|
||||
arrayvec::ArrayString,
|
||||
std::{
|
||||
fmt::{Display, Formatter},
|
||||
str::FromStr,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
|
||||
pub struct ActivationToken(Opaque);
|
||||
|
||||
pub fn activation_token() -> ActivationToken {
|
||||
ActivationToken(opaque())
|
||||
}
|
||||
|
||||
impl ActivationToken {
|
||||
pub fn to_string(self) -> ArrayString<OPAQUE_LEN> {
|
||||
self.0.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ActivationToken {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for ActivationToken {
|
||||
type Err = OpaqueError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(Self(s.parse()?))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
use {
|
||||
crate::utils::{
|
||||
clonecell::UnsafeCellCloneSafe,
|
||||
opaque::{OPAQUE_LEN, Opaque, OpaqueError, opaque},
|
||||
},
|
||||
arrayvec::ArrayString,
|
||||
std::{
|
||||
fmt::{Display, Formatter},
|
||||
str::FromStr,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Ord, PartialOrd)]
|
||||
pub struct ToplevelIdentifier(Opaque);
|
||||
|
||||
unsafe impl UnsafeCellCloneSafe for ToplevelIdentifier {}
|
||||
|
||||
pub fn toplevel_identifier() -> ToplevelIdentifier {
|
||||
ToplevelIdentifier(opaque())
|
||||
}
|
||||
|
||||
impl ToplevelIdentifier {
|
||||
pub fn to_string(self) -> ArrayString<OPAQUE_LEN> {
|
||||
self.0.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ToplevelIdentifier {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for ToplevelIdentifier {
|
||||
type Err = OpaqueError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(Self(s.parse()?))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue