cairo_vm/types/
layout_name.rs

1#[cfg(feature = "test_utils")]
2use arbitrary::{self, Arbitrary};
3#[cfg(all(feature = "clap", feature = "std"))]
4use clap::{builder::PossibleValue, ValueEnum};
5use core::fmt::{self, Display};
6use serde::{Deserialize, Serialize};
7
8/// Enum representing the name of a Cairo Layout
9#[cfg_attr(feature = "test_utils", derive(Arbitrary))]
10#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone, Eq, Hash)]
11#[allow(non_camel_case_types)]
12pub enum LayoutName {
13    plain,
14    small,
15    dex,
16    recursive,
17    starknet,
18    starknet_with_keccak,
19    recursive_large_output,
20    recursive_with_poseidon,
21    all_solidity,
22    all_cairo,
23    dynamic,
24    all_cairo_stwo,
25    perpetual,
26    dex_with_bitwise,
27}
28
29impl LayoutName {
30    pub fn to_str(self) -> &'static str {
31        match self {
32            LayoutName::plain => "plain",
33            LayoutName::small => "small",
34            LayoutName::dex => "dex",
35            LayoutName::recursive => "recursive",
36            LayoutName::starknet => "starknet",
37            LayoutName::starknet_with_keccak => "starknet_with_keccak",
38            LayoutName::recursive_large_output => "recursive_large_output",
39            LayoutName::recursive_with_poseidon => "recursive_with_poseidon",
40            LayoutName::all_solidity => "all_solidity",
41            LayoutName::all_cairo => "all_cairo",
42            LayoutName::dynamic => "dynamic",
43            LayoutName::all_cairo_stwo => "all_cairo_stwo",
44            LayoutName::perpetual => "perpetual",
45            LayoutName::dex_with_bitwise => "dex_with_bitwise",
46        }
47    }
48}
49
50impl Display for LayoutName {
51    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52        self.to_str().fmt(f)
53    }
54}
55
56#[cfg(all(feature = "clap", feature = "std"))]
57impl ValueEnum for LayoutName {
58    fn value_variants<'a>() -> &'a [Self] {
59        &[
60            Self::plain,
61            Self::small,
62            Self::dex,
63            Self::recursive,
64            Self::starknet,
65            Self::starknet_with_keccak,
66            Self::recursive_large_output,
67            Self::recursive_with_poseidon,
68            Self::all_solidity,
69            Self::all_cairo,
70            Self::dynamic,
71            Self::all_cairo_stwo,
72            Self::perpetual,
73            Self::dex_with_bitwise,
74        ]
75    }
76
77    fn to_possible_value(&self) -> Option<PossibleValue> {
78        Some(PossibleValue::new(self.to_str()))
79    }
80}