/ console / program / src / data / literal / to_type.rs
to_type.rs
 1  // Copyright (c) 2019-2025 Alpha-Delta Network Inc.
 2  // This file is part of the alphavm library.
 3  
 4  // Licensed under the Apache License, Version 2.0 (the "License");
 5  // you may not use this file except in compliance with the License.
 6  // You may obtain a copy of the License at:
 7  
 8  // http://www.apache.org/licenses/LICENSE-2.0
 9  
10  // Unless required by applicable law or agreed to in writing, software
11  // distributed under the License is distributed on an "AS IS" BASIS,
12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  // See the License for the specific language governing permissions and
14  // limitations under the License.
15  
16  use super::*;
17  
18  impl<N: Network> Literal<N> {
19      /// Returns the type name of the literal.
20      pub fn to_type(&self) -> LiteralType {
21          match self {
22              Self::Address(..) => LiteralType::Address,
23              Self::Boolean(..) => LiteralType::Boolean,
24              Self::Field(..) => LiteralType::Field,
25              Self::Group(..) => LiteralType::Group,
26              Self::I8(..) => LiteralType::I8,
27              Self::I16(..) => LiteralType::I16,
28              Self::I32(..) => LiteralType::I32,
29              Self::I64(..) => LiteralType::I64,
30              Self::I128(..) => LiteralType::I128,
31              Self::U8(..) => LiteralType::U8,
32              Self::U16(..) => LiteralType::U16,
33              Self::U32(..) => LiteralType::U32,
34              Self::U64(..) => LiteralType::U64,
35              Self::U128(..) => LiteralType::U128,
36              Self::Scalar(..) => LiteralType::Scalar,
37              Self::Signature(..) => LiteralType::Signature,
38              Self::String(..) => LiteralType::String,
39          }
40      }
41  }