Skip to main content

canton_splice_api_token_holding_v2/
lib.rs

1#![forbid(unsafe_code)]
2#![allow(non_camel_case_types, non_snake_case, unused_imports, clippy::all)]
3//! Typed Rust bindings generated from a Daml archive (DAR).
4//!
5//! **Generated file — do not edit by hand.** Regenerate with
6//! `dpm-codegen-rust` from the source this crate's `Cargo.toml` records
7//! (a DAR, or a participant's package payloads); edits are lost.
8//!
9//! Each Daml package in the DAR's dependency closure is one top-level
10//! module, and each Daml module a submodule under it, so cross-package
11//! references resolve and names never collide. Templates carry typed
12//! choices; the runtime traits they implement (`Template`, `Choice`,
13//! `Contract`) and the command builders live in `canton-daml`, which the
14//! generated code imports as `rt`.
15//!
16//! # Packages in this crate
17//!
18//! - [`splice_api_token_holding_v2`] — 1 Daml module
19
20pub mod splice_api_token_holding_v2 {
21    pub mod Splice_Api_Token_HoldingV2 {
22        use canton_daml as rt;
23        #[derive(Clone, Debug, PartialEq, Eq, rt::serde::Serialize, rt::serde::Deserialize)]
24        #[serde(crate = "rt::serde")]
25        pub struct HoldingView {
26            #[serde(rename = "account")]
27            pub account: crate::splice_api_token_holding_v2::Splice_Api_Token_HoldingV2::Account,
28            ///Daml field `instrumentId`.
29            #[serde(rename = "instrumentId")]
30            pub instrument_id: crate::splice_api_token_holding_v2::Splice_Api_Token_HoldingV2::InstrumentId,
31            #[serde(rename = "amount")]
32            pub amount: rt::Numeric,
33            #[serde(rename = "lock")]
34            pub lock: ::core::option::Option<
35                crate::splice_api_token_holding_v2::Splice_Api_Token_HoldingV2::Lock,
36            >,
37            #[serde(rename = "meta")]
38            pub meta: ::canton_splice_api_token_metadata_v1::splice_api_token_metadata_v1::Splice_Api_Token_MetadataV1::Metadata,
39        }
40        impl rt::ToValue for HoldingView {
41            fn to_value(&self) -> rt::Value {
42                rt::record(::std::vec![
43                    ("account", rt::ToValue::to_value(&self.account)),
44                    ("instrumentId", rt::ToValue::to_value(&self.instrument_id)),
45                    ("amount", rt::ToValue::to_value(&self.amount)),
46                    ("lock", rt::ToValue::to_value(&self.lock)),
47                    ("meta", rt::ToValue::to_value(&self.meta)),
48                ])
49            }
50        }
51        impl rt::FromValue for HoldingView {
52            fn from_value(value: &rt::Value) -> ::core::result::Result<Self, rt::ValueError> {
53                ::core::result::Result::Ok(Self {
54                    account: rt::FromValue::from_value(rt::required_field(
55                        value, 0usize, "account",
56                    )?)
57                    .map_err(|e| e.at("account"))?,
58                    instrument_id: rt::FromValue::from_value(rt::required_field(
59                        value,
60                        1usize,
61                        "instrumentId",
62                    )?)
63                    .map_err(|e| e.at("instrumentId"))?,
64                    amount: rt::FromValue::from_value(rt::required_field(value, 2usize, "amount")?)
65                        .map_err(|e| e.at("amount"))?,
66                    lock: rt::optional_field(value, 3usize, "lock").map_err(|e| e.at("lock"))?,
67                    meta: rt::FromValue::from_value(rt::required_field(value, 4usize, "meta")?)
68                        .map_err(|e| e.at("meta"))?,
69                })
70            }
71        }
72        #[derive(Clone, Debug, PartialEq, Eq, rt::serde::Serialize, rt::serde::Deserialize)]
73        #[serde(crate = "rt::serde")]
74        pub struct Lock {
75            #[serde(rename = "holders")]
76            pub holders: ::std::vec::Vec<rt::Party>,
77            ///Daml field `expiresAt`.
78            #[serde(rename = "expiresAt")]
79            pub expires_at: ::core::option::Option<rt::Timestamp>,
80            ///Daml field `expiresAfter`.
81            #[serde(rename = "expiresAfter")]
82            pub expires_after: ::core::option::Option<
83                ::canton_daml_stdlib::daml_stdlib_DA_Time_Types::DA_Time_Types::RelTime,
84            >,
85            #[serde(rename = "context")]
86            pub context: ::core::option::Option<::std::string::String>,
87        }
88        impl rt::ToValue for Lock {
89            fn to_value(&self) -> rt::Value {
90                rt::record(::std::vec![
91                    ("holders", rt::ToValue::to_value(&self.holders)),
92                    ("expiresAt", rt::ToValue::to_value(&self.expires_at)),
93                    ("expiresAfter", rt::ToValue::to_value(&self.expires_after)),
94                    ("context", rt::ToValue::to_value(&self.context)),
95                ])
96            }
97        }
98        impl rt::FromValue for Lock {
99            fn from_value(value: &rt::Value) -> ::core::result::Result<Self, rt::ValueError> {
100                ::core::result::Result::Ok(Self {
101                    holders: rt::FromValue::from_value(rt::required_field(
102                        value, 0usize, "holders",
103                    )?)
104                    .map_err(|e| e.at("holders"))?,
105                    expires_at: rt::optional_field(value, 1usize, "expiresAt")
106                        .map_err(|e| e.at("expiresAt"))?,
107                    expires_after: rt::optional_field(value, 2usize, "expiresAfter")
108                        .map_err(|e| e.at("expiresAfter"))?,
109                    context: rt::optional_field(value, 3usize, "context")
110                        .map_err(|e| e.at("context"))?,
111                })
112            }
113        }
114        #[derive(Clone, Debug, PartialEq, Eq, rt::serde::Serialize, rt::serde::Deserialize)]
115        #[serde(crate = "rt::serde")]
116        pub struct Account {
117            #[serde(rename = "owner")]
118            pub owner: ::core::option::Option<rt::Party>,
119            #[serde(rename = "provider")]
120            pub provider: ::core::option::Option<rt::Party>,
121            #[serde(rename = "id")]
122            pub id: ::std::string::String,
123        }
124        impl rt::ToValue for Account {
125            fn to_value(&self) -> rt::Value {
126                rt::record(::std::vec![
127                    ("owner", rt::ToValue::to_value(&self.owner)),
128                    ("provider", rt::ToValue::to_value(&self.provider)),
129                    ("id", rt::ToValue::to_value(&self.id)),
130                ])
131            }
132        }
133        impl rt::FromValue for Account {
134            fn from_value(value: &rt::Value) -> ::core::result::Result<Self, rt::ValueError> {
135                ::core::result::Result::Ok(Self {
136                    owner: rt::optional_field(value, 0usize, "owner").map_err(|e| e.at("owner"))?,
137                    provider: rt::optional_field(value, 1usize, "provider")
138                        .map_err(|e| e.at("provider"))?,
139                    id: rt::FromValue::from_value(rt::required_field(value, 2usize, "id")?)
140                        .map_err(|e| e.at("id"))?,
141                })
142            }
143        }
144        #[derive(Clone, Debug, PartialEq, Eq, rt::serde::Serialize, rt::serde::Deserialize)]
145        #[serde(crate = "rt::serde")]
146        pub struct InstrumentId {
147            #[serde(rename = "admin")]
148            pub admin: rt::Party,
149            #[serde(rename = "id")]
150            pub id: ::std::string::String,
151        }
152        impl rt::ToValue for InstrumentId {
153            fn to_value(&self) -> rt::Value {
154                rt::record(::std::vec![
155                    ("admin", rt::ToValue::to_value(&self.admin)),
156                    ("id", rt::ToValue::to_value(&self.id)),
157                ])
158            }
159        }
160        impl rt::FromValue for InstrumentId {
161            fn from_value(value: &rt::Value) -> ::core::result::Result<Self, rt::ValueError> {
162                ::core::result::Result::Ok(Self {
163                    admin: rt::FromValue::from_value(rt::required_field(value, 0usize, "admin")?)
164                        .map_err(|e| e.at("admin"))?,
165                    id: rt::FromValue::from_value(rt::required_field(value, 1usize, "id")?)
166                        .map_err(|e| e.at("id"))?,
167                })
168            }
169        }
170        ///Marker for the Daml interface `Holding` (held via `ContractId`).
171        #[derive(Clone, Copy, Debug, PartialEq, Eq)]
172        pub struct Holding;
173        impl rt::Contract for Holding {
174            const PACKAGE_ID: &'static str =
175                "4b7ecfc366d79ccc5ed07c80f26fe489cf2dfd43ce2856c06a78e6a048db7032";
176            const PACKAGE_NAME: &'static str = "splice-api-token-holding-v2";
177            const MODULE_NAME: &'static str = "Splice.Api.Token.HoldingV2";
178            const ENTITY_NAME: &'static str = "Holding";
179        }
180        impl rt::Interface for Holding {
181            type View = crate::splice_api_token_holding_v2::Splice_Api_Token_HoldingV2::HoldingView;
182        }
183        ///The `Archive` choice on [`Holding`] (consuming).
184        impl rt::Choice<Holding>
185            for ::canton_daml_stdlib::ghc_stdlib_DA_Internal_Template::DA_Internal_Template::Archive
186        {
187            type Return = rt::Unit;
188            const NAME: &'static str = "Archive";
189            const CONSUMING: bool = true;
190        }
191    }
192}