[][src]Trait candid::codegen::LanguageBinding

pub trait LanguageBinding {
    fn usage_prim(&self, ty: &PrimType) -> Result<String>;
fn usage_var(&self, var: &str) -> Result<String>;
fn usage_func(&self, func: &FuncType) -> Result<String>;
fn usage_opt(&self, ty: &IDLType) -> Result<String>;
fn usage_vec(&self, ty: &IDLType) -> Result<String>;
fn usage_record(&self, fields: &[TypeField]) -> Result<String>;
fn usage_variant(&self, fields: &[TypeField]) -> Result<String>;
fn usage_service(&self, ty: &[Binding]) -> Result<String>;
fn declare_prim(&self, id: &str, ty: &PrimType) -> Result<String>;
fn declare_var(&self, id: &str, var: &str) -> Result<String>;
fn declare_func(&self, id: &str, func: &FuncType) -> Result<String>;
fn declare_opt(&self, id: &str, ty: &IDLType) -> Result<String>;
fn declare_vec(&self, id: &str, ty: &IDLType) -> Result<String>;
fn declare_record(&self, id: &str, fields: &[TypeField]) -> Result<String>;
fn declare_variant(&self, id: &str, fields: &[TypeField]) -> Result<String>;
fn declare_service(&self, id: &str, ty: &[Binding]) -> Result<String>;
fn service_binding(&self, id: &str, typ: &FuncType) -> Result<String>; fn start(&self) -> Result<()> { ... }
fn done(&self, output: String) -> Result<String> { ... }
fn header(&self) -> Result<String> { ... }
fn footer(&self) -> Result<String> { ... }
fn usage(&self, ty: &IDLType) -> Result<String> { ... }
fn declare(&self, id: &str, ty: &IDLType) -> Result<String> { ... }
fn declaration_import(&self, _module: &str) -> Result<String> { ... }
fn declaration_binding(&self, binding: &Binding) -> Result<String> { ... }
fn declarations(&self, declarations: &[Dec]) -> Result<String> { ... }
fn service(&self, bindings: &[Binding]) -> Result<String> { ... }
fn prog(&self, prog: &IDLProg) -> Result<String> { ... } }

Required methods

fn usage_prim(&self, ty: &PrimType) -> Result<String>

String to use when using a primary type as a right hand side.

fn usage_var(&self, var: &str) -> Result<String>

String to use when using a var reference as a right hand side.

fn usage_func(&self, func: &FuncType) -> Result<String>

String to use when using a function type as a right hand side.

fn usage_opt(&self, ty: &IDLType) -> Result<String>

String to use when using an optional type as a right hand side.

fn usage_vec(&self, ty: &IDLType) -> Result<String>

String to use when using a vector type as a right hand side.

fn usage_record(&self, fields: &[TypeField]) -> Result<String>

String to use when using a record type as a right hand side.

fn usage_variant(&self, fields: &[TypeField]) -> Result<String>

String to use when using a variant type as a right hand side.

fn usage_service(&self, ty: &[Binding]) -> Result<String>

String to use when using a service type as a right hand side.

fn declare_prim(&self, id: &str, ty: &PrimType) -> Result<String>

Function called when declaring a primary type.

fn declare_var(&self, id: &str, var: &str) -> Result<String>

Function called when declaring a var reference type.

fn declare_func(&self, id: &str, func: &FuncType) -> Result<String>

Function called when declaring a function type.

fn declare_opt(&self, id: &str, ty: &IDLType) -> Result<String>

Function called when declaring a optional type.

fn declare_vec(&self, id: &str, ty: &IDLType) -> Result<String>

Function called when declaring a vector type.

fn declare_record(&self, id: &str, fields: &[TypeField]) -> Result<String>

Function called when declaring a record type.

fn declare_variant(&self, id: &str, fields: &[TypeField]) -> Result<String>

Function called when declaring a variant type.

fn declare_service(&self, id: &str, ty: &[Binding]) -> Result<String>

Function called when declaring a service type.

fn service_binding(&self, id: &str, typ: &FuncType) -> Result<String>

Function called when declaring a binding inside a service.

Loading content...

Provided methods

fn start(&self) -> Result<()>

Called when the program starts to be analyzed.

fn done(&self, output: String) -> Result<String>

Called when the code generation is done, with the output intended. The return value of this function will be the actual string outputted.

fn header(&self) -> Result<String>

The header string that will be prepended to the output.

fn footer(&self) -> Result<String>

The footer string that will be appended to the output.

fn usage(&self, ty: &IDLType) -> Result<String>

This method is called when a type is used as a right hand side. By default it forwards it to a specialized method for each type.

fn declare(&self, id: &str, ty: &IDLType) -> Result<String>

String to use when declaring a type. This receives the ID of the type, and the right hand side of the type itself. By default it forwards it to a specialized method for each type.

fn declaration_import(&self, _module: &str) -> Result<String>

Function called when an import statement is used.

fn declaration_binding(&self, binding: &Binding) -> Result<String>

Function called when a declaration binding is used.

fn declarations(&self, declarations: &[Dec]) -> Result<String>

Function called for all declarations in a Candid file.

fn service(&self, bindings: &[Binding]) -> Result<String>

Function called when declaring the service (or actor) of a candid file. By default returns the result of calling [service_binding] on all bindings, and returning a string separated by \n.

fn prog(&self, prog: &IDLProg) -> Result<String>

The main function which is called when starting the code generation.

Loading content...

Implementors

Loading content...