Trait wai_bindgen_gen_rust::RustGenerator
source · pub trait RustGenerator {
Show 39 methods
// Required methods
fn push_str(&mut self, s: &str);
fn info(&self, ty: TypeId) -> TypeInfo;
fn types_mut(&mut self) -> &mut Types;
fn print_borrowed_slice(
&mut self,
iface: &Interface,
mutbl: bool,
ty: &Type,
lifetime: &'static str
);
fn print_borrowed_str(&mut self, lifetime: &'static str);
fn default_param_mode(&self) -> TypeMode;
fn handle_projection(&self) -> Option<(&'static str, String)>;
fn handle_wrapper(&self) -> Option<&'static str>;
// Provided methods
fn handle_in_super(&self) -> bool { ... }
fn always_generate_structs(&self) -> bool { ... }
fn rustdoc(&mut self, docs: &Docs) { ... }
fn rustdoc_params(&mut self, docs: &[(String, Type)], header: &str) { ... }
fn print_signature(
&mut self,
iface: &Interface,
func: &Function,
param_mode: TypeMode,
sig: &FnSig
) -> Vec<String> { ... }
fn print_docs_and_params(
&mut self,
iface: &Interface,
func: &Function,
param_mode: TypeMode,
sig: &FnSig
) -> Vec<String> { ... }
fn print_ty(&mut self, iface: &Interface, ty: &Type, mode: TypeMode) { ... }
fn print_tyid(&mut self, iface: &Interface, id: TypeId, mode: TypeMode) { ... }
fn print_list(&mut self, iface: &Interface, ty: &Type, mode: TypeMode) { ... }
fn print_rust_slice(
&mut self,
iface: &Interface,
mutbl: bool,
ty: &Type,
lifetime: &'static str
) { ... }
fn print_generics(
&mut self,
info: &TypeInfo,
lifetime: Option<&str>,
bound: bool
) { ... }
fn int_repr(&mut self, repr: Int) { ... }
fn wasm_type(&mut self, ty: WasmType) { ... }
fn modes_of(&self, iface: &Interface, ty: TypeId) -> Vec<(String, TypeMode)> { ... }
fn write_name(&self, iface: &Interface, ty: &Type, out: &mut String) { ... }
fn union_case_names(&self, iface: &Interface, union: &Union) -> Vec<String> { ... }
fn print_typedef_record(
&mut self,
iface: &Interface,
id: TypeId,
record: &Record,
docs: &Docs
) { ... }
fn print_typedef_tuple(
&mut self,
iface: &Interface,
id: TypeId,
tuple: &Tuple,
docs: &Docs
) { ... }
fn print_typedef_variant(
&mut self,
iface: &Interface,
id: TypeId,
variant: &Variant,
docs: &Docs
)
where Self: Sized { ... }
fn print_typedef_union(
&mut self,
iface: &Interface,
id: TypeId,
union: &Union,
docs: &Docs
)
where Self: Sized { ... }
fn print_rust_enum<'a>(
&mut self,
iface: &Interface,
id: TypeId,
cases: impl IntoIterator<Item = (String, &'a Docs, &'a Type)> + Clone,
docs: &Docs
)
where Self: Sized { ... }
fn print_rust_enum_debug<'a>(
&mut self,
id: TypeId,
mode: TypeMode,
name: &str,
cases: impl IntoIterator<Item = (String, &'a Type)>
)
where Self: Sized { ... }
fn print_typedef_option(
&mut self,
iface: &Interface,
id: TypeId,
payload: &Type,
docs: &Docs
) { ... }
fn print_typedef_expected(
&mut self,
iface: &Interface,
id: TypeId,
expected: &Expected,
docs: &Docs
) { ... }
fn print_typedef_enum(
&mut self,
id: TypeId,
name: &str,
enum_: &Enum,
docs: &Docs
)
where Self: Sized { ... }
fn print_typedef_alias(
&mut self,
iface: &Interface,
id: TypeId,
ty: &Type,
docs: &Docs
) { ... }
fn print_type_list(
&mut self,
iface: &Interface,
id: TypeId,
ty: &Type,
docs: &Docs
) { ... }
fn param_name(&self, iface: &Interface, ty: TypeId) -> String { ... }
fn result_name(&self, iface: &Interface, ty: TypeId) -> String { ... }
fn uses_two_names(&self, info: &TypeInfo) -> bool { ... }
fn lifetime_for(
&self,
info: &TypeInfo,
mode: TypeMode
) -> Option<&'static str> { ... }
}
Required Methods§
fn push_str(&mut self, s: &str)
fn info(&self, ty: TypeId) -> TypeInfo
fn types_mut(&mut self) -> &mut Types
fn print_borrowed_slice( &mut self, iface: &Interface, mutbl: bool, ty: &Type, lifetime: &'static str )
fn print_borrowed_str(&mut self, lifetime: &'static str)
fn default_param_mode(&self) -> TypeMode
fn handle_projection(&self) -> Option<(&'static str, String)>
fn handle_wrapper(&self) -> Option<&'static str>
Provided Methods§
fn handle_in_super(&self) -> bool
sourcefn always_generate_structs(&self) -> bool
fn always_generate_structs(&self) -> bool
Make the code generator always generate types, even if they are never used.
fn rustdoc(&mut self, docs: &Docs)
fn rustdoc_params(&mut self, docs: &[(String, Type)], header: &str)
fn print_signature( &mut self, iface: &Interface, func: &Function, param_mode: TypeMode, sig: &FnSig ) -> Vec<String>
fn print_docs_and_params( &mut self, iface: &Interface, func: &Function, param_mode: TypeMode, sig: &FnSig ) -> Vec<String>
fn print_ty(&mut self, iface: &Interface, ty: &Type, mode: TypeMode)
fn print_tyid(&mut self, iface: &Interface, id: TypeId, mode: TypeMode)
fn print_list(&mut self, iface: &Interface, ty: &Type, mode: TypeMode)
fn print_rust_slice( &mut self, iface: &Interface, mutbl: bool, ty: &Type, lifetime: &'static str )
fn print_generics(&mut self, info: &TypeInfo, lifetime: Option<&str>, bound: bool)
fn int_repr(&mut self, repr: Int)
fn wasm_type(&mut self, ty: WasmType)
fn modes_of(&self, iface: &Interface, ty: TypeId) -> Vec<(String, TypeMode)>
sourcefn write_name(&self, iface: &Interface, ty: &Type, out: &mut String)
fn write_name(&self, iface: &Interface, ty: &Type, out: &mut String)
Writes the camel-cased ‘name’ of the passed type to out
, as used to name union variants.
sourcefn union_case_names(&self, iface: &Interface, union: &Union) -> Vec<String>
fn union_case_names(&self, iface: &Interface, union: &Union) -> Vec<String>
Returns the names for the cases of the passed union.