use std::fmt::Debug;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum PathType {
Empty = 0,
Scion = 1,
OneHop = 2,
Epic = 3,
Colibri = 4,
Other(u8),
}
impl From<u8> for PathType {
fn from(value: u8) -> Self {
match value {
0 => PathType::Empty,
1 => PathType::Scion,
2 => PathType::OneHop,
3 => PathType::Epic,
4 => PathType::Colibri,
other => PathType::Other(other),
}
}
}
impl From<PathType> for u8 {
fn from(val: PathType) -> Self {
match val {
PathType::Empty => 0,
PathType::Scion => 1,
PathType::OneHop => 2,
PathType::Epic => 3,
PathType::Colibri => 4,
PathType::Other(other) => other,
}
}
}
#[cfg(feature = "proptest")]
pub mod ptest {
use ::proptest::prelude::*;
use super::*;
#[derive(Debug, Clone)]
pub struct ArbitraryPathTypeParams {
pub empty: u32,
pub scion: u32,
pub one_hop: u32,
pub epic: u32,
pub colibri: u32,
pub other: u32,
}
impl Default for ArbitraryPathTypeParams {
fn default() -> Self {
Self {
empty: 1,
scion: 4,
one_hop: 2,
epic: 1,
colibri: 1,
other: 1,
}
}
}
impl Arbitrary for PathType {
type Parameters = ArbitraryPathTypeParams;
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(params: Self::Parameters) -> Self::Strategy {
prop_oneof![
params.empty => Just(PathType::Empty),
params.scion => Just(PathType::Scion),
params.one_hop => Just(PathType::OneHop),
params.epic => Just(PathType::Epic),
params.colibri => Just(PathType::Colibri),
params.other => (5u8..=255).prop_map(PathType::Other),
]
.boxed()
}
}
}