pub use vitaminc_context::{Context, ContextPiece, IntoContext};
#[deprecated(
since = "0.5.0",
note = "renamed to `Context`, re-exported here from `vitaminc_context`"
)]
pub type Aad<'a> = Context<'a>;
#[deprecated(
since = "0.5.0",
note = "renamed to `ContextPiece`, re-exported here from `vitaminc_context`"
)]
pub type AadPiece<'a> = ContextPiece<'a>;
pub trait IntoAad<'a>: IntoContext<'a> {
fn into_aad(self) -> Context<'a>;
}
impl<'a, T> IntoAad<'a> for T
where
T: IntoContext<'a>,
{
fn into_aad(self) -> Context<'a> {
self.into_context().encode()
}
}
#[cfg(test)]
mod tests {
use super::*;
use quickcheck_macros::quickcheck;
use vitaminc_prf::IntoPrfContext;
#[quickcheck]
fn the_aad_and_the_prf_context_are_the_same_bytes(tree: ContextPiece<'static>) -> bool {
tree.clone().into_aad().as_bytes() == tree.into_prf_context().as_bytes()
}
#[test]
fn a_context_is_its_own_aad() {
let ctx = ("users/email", 7u64).into_aad();
assert_eq!(
ctx.clone().into_aad(),
ctx,
"an encoded context re-encodes to itself"
);
}
}