aws_db_esdk/deps/aws_cryptography_materialProviders/conversions/
cryptographic_materials_manager.rs

1// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
4#[allow(dead_code)]
5pub fn to_dafny(
6    value: &crate::deps::aws_cryptography_materialProviders::types::cryptographic_materials_manager::CryptographicMaterialsManagerRef,
7) -> ::dafny_runtime::Object<
8  dyn crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::ICryptographicMaterialsManager,
9>{
10    let wrap = CryptographicMaterialsManagerWrapper { obj: value.clone() };
11    let inner = ::dafny_runtime::Rc::new(::dafny_runtime::UnsafeCell::new(wrap));
12    ::dafny_runtime::Object(Some(inner))
13}
14
15pub struct CryptographicMaterialsManagerWrapper {
16  obj: crate::deps::aws_cryptography_materialProviders::types::cryptographic_materials_manager::CryptographicMaterialsManagerRef,
17}
18
19impl ::dafny_runtime::UpcastObject<::dafny_runtime::DynAny>
20    for CryptographicMaterialsManagerWrapper
21{
22    ::dafny_runtime::UpcastObjectFn!(::dafny_runtime::DynAny);
23}
24
25#[allow(dead_code)]
26pub fn from_dafny(
27    dafny_value: ::dafny_runtime::Object<
28      dyn crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::ICryptographicMaterialsManager,
29    >,
30) -> crate::deps::aws_cryptography_materialProviders::types::cryptographic_materials_manager::CryptographicMaterialsManagerRef{
31    let wrap = ICryptographicMaterialsManagerDafnyWrapper {
32        obj: dafny_value.clone(),
33    };
34    crate::deps::aws_cryptography_materialProviders::types::cryptographic_materials_manager::CryptographicMaterialsManagerRef {
35      inner: ::dafny_runtime::Rc::new(::dafny_runtime::RefCell::new(wrap))
36    }
37}
38
39#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
40pub struct ICryptographicMaterialsManagerDafnyWrapper {
41  pub(crate) obj: ::dafny_runtime::Object<
42      dyn crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::ICryptographicMaterialsManager,
43  >,
44}
45
46impl crate::software::amazon::cryptography::materialproviders::internaldafny::types::ICryptographicMaterialsManager
47  for CryptographicMaterialsManagerWrapper
48{
49  fn r#_GetEncryptionMaterials_k(
50    &self,
51    input: &::dafny_runtime::Rc<crate::software::amazon::cryptography::materialproviders::internaldafny::types::GetEncryptionMaterialsInput>,
52) -> ::dafny_runtime::Rc<
53    crate::r#_Wrappers_Compile::Result<
54        ::dafny_runtime::Rc<crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::GetEncryptionMaterialsOutput>,
55        ::dafny_runtime::Rc<crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::Error>,
56    >,
57>
58{
59    let inner_input = crate::deps::aws_cryptography_materialProviders::conversions::get_encryption_materials::_get_encryption_materials_input::from_dafny(input.clone());
60    let inner_result = self.obj.inner.lock().unwrap().get_encryption_materials(inner_input);
61    let result = match inner_result {
62        Ok(x) => crate::r#_Wrappers_Compile::Result::Success {
63            value: crate::deps::aws_cryptography_materialProviders::conversions::get_encryption_materials::_get_encryption_materials_output::to_dafny(x.clone()),
64        },
65        Err(x) => crate::r#_Wrappers_Compile::Result::Failure {
66            error: crate::deps::aws_cryptography_materialProviders::conversions::error::to_dafny(x),
67        },
68    };
69    ::dafny_runtime::Rc::new(result)
70}
71
72fn r#_DecryptMaterials_k(
73    &self,
74    input: &::dafny_runtime::Rc<crate::software::amazon::cryptography::materialproviders::internaldafny::types::DecryptMaterialsInput>,
75) -> ::dafny_runtime::Rc<
76    crate::r#_Wrappers_Compile::Result<
77        ::dafny_runtime::Rc<crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::DecryptMaterialsOutput>,
78        ::dafny_runtime::Rc<crate::r#software::amazon::cryptography::materialproviders::internaldafny::types::Error>,
79    >,
80>
81{
82    let inner_input = crate::deps::aws_cryptography_materialProviders::conversions::decrypt_materials::_decrypt_materials_input::from_dafny(input.clone());
83    let inner_result = self.obj.inner.lock().unwrap().decrypt_materials(inner_input);
84    let result = match inner_result {
85        Ok(x) => crate::r#_Wrappers_Compile::Result::Success {
86            value: crate::deps::aws_cryptography_materialProviders::conversions::decrypt_materials::_decrypt_materials_output::to_dafny(x.clone()),
87        },
88        Err(x) => crate::r#_Wrappers_Compile::Result::Failure {
89            error: crate::deps::aws_cryptography_materialProviders::conversions::error::to_dafny(x),
90        },
91    };
92    ::dafny_runtime::Rc::new(result)
93}
94}
95
96impl crate::deps::aws_cryptography_materialProviders::types::cryptographic_materials_manager::CryptographicMaterialsManager for ICryptographicMaterialsManagerDafnyWrapper
97{
98  fn get_encryption_materials(
99  &self,
100  input: crate::deps::aws_cryptography_materialProviders::operation::get_encryption_materials::GetEncryptionMaterialsInput,
101) -> Result<
102  crate::deps::aws_cryptography_materialProviders::operation::get_encryption_materials::GetEncryptionMaterialsOutput,
103  crate::deps::aws_cryptography_materialProviders::types::error::Error,
104> {
105  let inner_input = crate::deps::aws_cryptography_materialProviders::conversions::get_encryption_materials::_get_encryption_materials_input::to_dafny(input);
106  let inner_result = ::dafny_runtime::md!(self.obj.clone()).GetEncryptionMaterials(&inner_input);
107  if matches!(
108      inner_result.as_ref(),
109      crate::r#_Wrappers_Compile::Result::Success { .. }
110  ) {
111      Ok(
112          crate::deps::aws_cryptography_materialProviders::conversions::get_encryption_materials::_get_encryption_materials_output::from_dafny(inner_result.value().clone()),
113      )
114  } else {
115      Err(crate::deps::aws_cryptography_materialProviders::conversions::error::from_dafny(
116          inner_result.error().clone(),
117      ))
118  }
119}
120
121fn decrypt_materials(
122  &self,
123  input: crate::deps::aws_cryptography_materialProviders::operation::decrypt_materials::DecryptMaterialsInput,
124) -> Result<
125  crate::deps::aws_cryptography_materialProviders::operation::decrypt_materials::DecryptMaterialsOutput,
126  crate::deps::aws_cryptography_materialProviders::types::error::Error,
127> {
128  let inner_input = crate::deps::aws_cryptography_materialProviders::conversions::decrypt_materials::_decrypt_materials_input::to_dafny(input);
129  let inner_result = ::dafny_runtime::md!(self.obj.clone()).DecryptMaterials(&inner_input);
130  if matches!(
131      inner_result.as_ref(),
132      crate::r#_Wrappers_Compile::Result::Success { .. }
133  ) {
134      Ok(
135          crate::deps::aws_cryptography_materialProviders::conversions::decrypt_materials::_decrypt_materials_output::from_dafny(inner_result.value().clone()),
136      )
137  } else {
138      Err(crate::deps::aws_cryptography_materialProviders::conversions::error::from_dafny(
139          inner_result.error().clone(),
140      ))
141  }
142}
143}