snarkvm_synthesizer_program/mapping/
mod.rs1mod key;
17use key::*;
18
19mod value;
20use value::*;
21
22mod bytes;
23mod parse;
24
25use console::{network::prelude::*, program::Identifier};
26
27#[derive(Clone, PartialEq, Eq)]
28pub struct Mapping<N: Network> {
29 name: Identifier<N>,
31 key: MapKey<N>,
33 value: MapValue<N>,
35}
36
37impl<N: Network> Mapping<N> {
38 pub fn new(name: Identifier<N>, key: MapKey<N>, value: MapValue<N>) -> Self {
40 Self { name, key, value }
41 }
42
43 pub const fn name(&self) -> &Identifier<N> {
45 &self.name
46 }
47
48 pub const fn key(&self) -> &MapKey<N> {
50 &self.key
51 }
52
53 pub const fn value(&self) -> &MapValue<N> {
55 &self.value
56 }
57
58 pub fn contains_external_struct(&self) -> bool {
59 self.key.plaintext_type().contains_external_struct() || self.value.plaintext_type().contains_external_struct()
60 }
61
62 pub fn contains_string_type(&self) -> bool {
64 self.key.plaintext_type().contains_string_type() || self.value.plaintext_type().contains_string_type()
65 }
66
67 pub fn exceeds_max_array_size(&self, max_array_size: u32) -> bool {
69 self.key.plaintext_type().exceeds_max_array_size(max_array_size)
70 || self.value.plaintext_type().exceeds_max_array_size(max_array_size)
71 }
72}
73
74impl<N: Network> TypeName for Mapping<N> {
75 #[inline]
77 fn type_name() -> &'static str {
78 "mapping"
79 }
80}