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§

source

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§

source

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.

source

fn literal(&self, _literal: &Literal) -> String

source

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.

source

fn lower(&self) -> String

An expression for lowering a value into something we can pass over the FFI.

source

fn write(&self) -> String

An expression for writing a value into a byte buffer.

source

fn lift(&self) -> String

An expression for lifting a value from something we received over the FFI.

source

fn read(&self) -> String

An expression for reading a value from a byte buffer.

source

fn imports(&self) -> Option<Vec<String>>

A list of imports that are needed if this type is in use. Classes are imported exactly once.

source

fn initialization_fn(&self) -> Option<String>

Function to run at startup

Implementors§