1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use crate::element::daml_expr::DamlExpr;
use crate::element::{DamlElementVisitor, DamlType, DamlVisitableElement};
use bounded_static::ToStatic;
use serde::Serialize;
use std::borrow::Cow;
#[derive(Debug, Serialize, Clone, ToStatic)]
pub struct DamlDefValue<'a> {
pub name: Cow<'a, str>,
pub ty: DamlType<'a>,
pub expr: DamlExpr<'a>,
pub no_party_literals: bool,
pub is_test: bool,
}
impl<'a> DamlDefValue<'a> {
pub const fn new(
name: Cow<'a, str>,
ty: DamlType<'a>,
expr: DamlExpr<'a>,
no_party_literals: bool,
is_test: bool,
) -> Self {
Self {
name,
ty,
expr,
no_party_literals,
is_test,
}
}
pub fn name(&self) -> &str {
&self.name
}
#[doc(hidden)]
pub fn name_clone(&self) -> Cow<'a, str> {
self.name.clone()
}
pub const fn ty(&self) -> &DamlType<'a> {
&self.ty
}
pub const fn expr(&self) -> &DamlExpr<'a> {
&self.expr
}
pub const fn no_party_literals(&self) -> bool {
self.no_party_literals
}
pub const fn is_test(&self) -> bool {
self.is_test
}
}
impl<'a> DamlVisitableElement<'a> for DamlDefValue<'a> {
fn accept(&'a self, visitor: &'a mut impl DamlElementVisitor) {
visitor.pre_visit_def_value(self);
self.ty.accept(visitor);
self.expr.accept(visitor);
visitor.post_visit_def_value(self);
}
}