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}
26
27impl LayoutName {
28    pub fn to_str(self) -> &'static str {
29        match self {
30            LayoutName::plain => "plain",
31            LayoutName::small => "small",
32            LayoutName::dex => "dex",
33            LayoutName::recursive => "recursive",
34            LayoutName::starknet => "starknet",
35            LayoutName::starknet_with_keccak => "starknet_with_keccak",
36            LayoutName::recursive_large_output => "recursive_large_output",
37            LayoutName::recursive_with_poseidon => "recursive_with_poseidon",
38            LayoutName::all_solidity => "all_solidity",
39            LayoutName::all_cairo => "all_cairo",
40            LayoutName::dynamic => "dynamic",
41            LayoutName::all_cairo_stwo => "all_cairo_stwo",
42        }
43    }
44}
45
46impl Display for LayoutName {
47    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48        self.to_str().fmt(f)
49    }
50}
51
52#[cfg(all(feature = "clap", feature = "std"))]
53impl ValueEnum for LayoutName {
54    fn value_variants<'a>() -> &'a [Self] {
55        &[
56            Self::plain,
57            Self::small,
58            Self::dex,
59            Self::recursive,
60            Self::starknet,
61            Self::starknet_with_keccak,
62            Self::recursive_large_output,
63            Self::recursive_with_poseidon,
64            Self::all_solidity,
65            Self::all_cairo,
66            Self::dynamic,
67            Self::all_cairo_stwo,
68        ]
69    }
70
71    fn to_possible_value(&self) -> Option<PossibleValue> {
72        Some(PossibleValue::new(self.to_str()))
73    }
74}