Trait uniffi_bindgen::backend::CodeType
source · pub trait CodeType: Debug {
// Required method
fn type_label(&self) -> String;
// Provided methods
fn canonical_name(&self) -> String { ... }
fn literal(&self, _literal: &Literal) -> String { ... }
fn ffi_converter_name(&self) -> String { ... }
fn lower(&self) -> String { ... }
fn write(&self) -> String { ... }
fn lift(&self) -> String { ... }
fn read(&self) -> String { ... }
fn imports(&self) -> Option<Vec<String>> { ... }
fn initialization_fn(&self) -> Option<String> { ... }
}
Expand description
A Trait to help render types in a language specific format.
Required Methods§
sourcefn type_label(&self) -> String
fn type_label(&self) -> String
The language specific label used to reference this type. This will be used in method signatures and property declarations.
Provided Methods§
sourcefn canonical_name(&self) -> String
fn canonical_name(&self) -> String
A representation of this type label that can be used as part of another
identifier. e.g. read_foo()
, or FooInternals
.
This is especially useful when creating specialized objects or methods to deal with this type only.
fn literal(&self, _literal: &Literal) -> String
sourcefn ffi_converter_name(&self) -> String
fn ffi_converter_name(&self) -> String
Name of the FfiConverter
This is the object that contains the lower, write, lift, and read methods for this type. Depending on the binding this will either be a singleton or a class with static methods.
This is the newer way of handling these methods and replaces the lower, write, lift, and read CodeType methods. Currently only used by Kotlin, but the plan is to move other backends to using this.
sourcefn lower(&self) -> String
fn lower(&self) -> String
An expression for lowering a value into something we can pass over the FFI.
sourcefn lift(&self) -> String
fn lift(&self) -> String
An expression for lifting a value from something we received over the FFI.
sourcefn imports(&self) -> Option<Vec<String>>
fn imports(&self) -> Option<Vec<String>>
A list of imports that are needed if this type is in use. Classes are imported exactly once.
sourcefn initialization_fn(&self) -> Option<String>
fn initialization_fn(&self) -> Option<String>
Function to run at startup