Skip to main content

canton_splice_api_token_holding_v1/
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_v1`] — 1 Daml module
19
20pub mod splice_api_token_holding_v1 {
21    pub mod Splice_Api_Token_HoldingV1 {
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 = "owner")]
27            pub owner: rt::Party,
28            ///Daml field `instrumentId`.
29            #[serde(rename = "instrumentId")]
30            pub instrument_id: crate::splice_api_token_holding_v1::Splice_Api_Token_HoldingV1::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_v1::Splice_Api_Token_HoldingV1::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                    ("owner", rt::ToValue::to_value(&self.owner)),
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                    owner: rt::FromValue::from_value(rt::required_field(value, 0usize, "owner")?)
55                        .map_err(|e| e.at("owner"))?,
56                    instrument_id: rt::FromValue::from_value(rt::required_field(
57                        value,
58                        1usize,
59                        "instrumentId",
60                    )?)
61                    .map_err(|e| e.at("instrumentId"))?,
62                    amount: rt::FromValue::from_value(rt::required_field(value, 2usize, "amount")?)
63                        .map_err(|e| e.at("amount"))?,
64                    lock: rt::optional_field(value, 3usize, "lock").map_err(|e| e.at("lock"))?,
65                    meta: rt::FromValue::from_value(rt::required_field(value, 4usize, "meta")?)
66                        .map_err(|e| e.at("meta"))?,
67                })
68            }
69        }
70        #[derive(Clone, Debug, PartialEq, Eq, rt::serde::Serialize, rt::serde::Deserialize)]
71        #[serde(crate = "rt::serde")]
72        pub struct Lock {
73            #[serde(rename = "holders")]
74            pub holders: ::std::vec::Vec<rt::Party>,
75            ///Daml field `expiresAt`.
76            #[serde(rename = "expiresAt")]
77            pub expires_at: ::core::option::Option<rt::Timestamp>,
78            ///Daml field `expiresAfter`.
79            #[serde(rename = "expiresAfter")]
80            pub expires_after: ::core::option::Option<
81                ::canton_daml_stdlib::daml_stdlib_DA_Time_Types::DA_Time_Types::RelTime,
82            >,
83            #[serde(rename = "context")]
84            pub context: ::core::option::Option<::std::string::String>,
85        }
86        impl rt::ToValue for Lock {
87            fn to_value(&self) -> rt::Value {
88                rt::record(::std::vec![
89                    ("holders", rt::ToValue::to_value(&self.holders)),
90                    ("expiresAt", rt::ToValue::to_value(&self.expires_at)),
91                    ("expiresAfter", rt::ToValue::to_value(&self.expires_after)),
92                    ("context", rt::ToValue::to_value(&self.context)),
93                ])
94            }
95        }
96        impl rt::FromValue for Lock {
97            fn from_value(value: &rt::Value) -> ::core::result::Result<Self, rt::ValueError> {
98                ::core::result::Result::Ok(Self {
99                    holders: rt::FromValue::from_value(rt::required_field(
100                        value, 0usize, "holders",
101                    )?)
102                    .map_err(|e| e.at("holders"))?,
103                    expires_at: rt::optional_field(value, 1usize, "expiresAt")
104                        .map_err(|e| e.at("expiresAt"))?,
105                    expires_after: rt::optional_field(value, 2usize, "expiresAfter")
106                        .map_err(|e| e.at("expiresAfter"))?,
107                    context: rt::optional_field(value, 3usize, "context")
108                        .map_err(|e| e.at("context"))?,
109                })
110            }
111        }
112        #[derive(Clone, Debug, PartialEq, Eq, rt::serde::Serialize, rt::serde::Deserialize)]
113        #[serde(crate = "rt::serde")]
114        pub struct InstrumentId {
115            #[serde(rename = "admin")]
116            pub admin: rt::Party,
117            #[serde(rename = "id")]
118            pub id: ::std::string::String,
119        }
120        impl rt::ToValue for InstrumentId {
121            fn to_value(&self) -> rt::Value {
122                rt::record(::std::vec![
123                    ("admin", rt::ToValue::to_value(&self.admin)),
124                    ("id", rt::ToValue::to_value(&self.id)),
125                ])
126            }
127        }
128        impl rt::FromValue for InstrumentId {
129            fn from_value(value: &rt::Value) -> ::core::result::Result<Self, rt::ValueError> {
130                ::core::result::Result::Ok(Self {
131                    admin: rt::FromValue::from_value(rt::required_field(value, 0usize, "admin")?)
132                        .map_err(|e| e.at("admin"))?,
133                    id: rt::FromValue::from_value(rt::required_field(value, 1usize, "id")?)
134                        .map_err(|e| e.at("id"))?,
135                })
136            }
137        }
138        ///Marker for the Daml interface `Holding` (held via `ContractId`).
139        #[derive(Clone, Copy, Debug, PartialEq, Eq)]
140        pub struct Holding;
141        impl rt::Contract for Holding {
142            const PACKAGE_ID: &'static str =
143                "718a0f77e505a8de22f188bd4c87fe74101274e9d4cb1bfac7d09aec7158d35b";
144            const PACKAGE_NAME: &'static str = "splice-api-token-holding-v1";
145            const MODULE_NAME: &'static str = "Splice.Api.Token.HoldingV1";
146            const ENTITY_NAME: &'static str = "Holding";
147        }
148        impl rt::Interface for Holding {
149            type View = crate::splice_api_token_holding_v1::Splice_Api_Token_HoldingV1::HoldingView;
150        }
151        ///The `Archive` choice on [`Holding`] (consuming).
152        impl rt::Choice<Holding>
153            for ::canton_daml_stdlib::ghc_stdlib_DA_Internal_Template::DA_Internal_Template::Archive
154        {
155            type Return = rt::Unit;
156            const NAME: &'static str = "Archive";
157            const CONSUMING: bool = true;
158        }
159    }
160}