Debian Codegraph @

third_party/rust/uniffi_bindgen/src/bindings/kotlin/gen_kotlin/variant.rs

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 use super::{AsCodeType, CodeType, KotlinCodeOracle};
6 use crate::interface::{ComponentInterface, Variant};
7
8 #[derive(Debug)]
9 pub(super) struct VariantCodeType {
10 pub v: Variant,
11 }
12
13 impl CodeType for VariantCodeType {
14 fn type_label(&self, ci: &ComponentInterface) -> String {
15 KotlinCodeOracle.class_name(ci, self.v.name())
16 }
17
18 fn canonical_name(&self) -> String {
19 self.v.name().to_string()
20 }
21 }
22
23 impl AsCodeType for Variant {
24 fn as_codetype(&self) -> Box<dyn CodeType> {
25 Box::new(VariantCodeType { v: self.clone() })
26 }
27 }
28
29 impl AsCodeType for &Variant {
30 fn as_codetype(&self) -> Box<dyn CodeType> {
31 Box::new(VariantCodeType { v: (*self).clone() })
32 }
33 }