Trait wit_bindgen_rust_lib::RustGenerator
source · pub trait RustGenerator<'a> {
Show 44 methods
// Required methods
fn resolve(&self) -> &'a Resolve;
fn path_to_interface(&self, interface: InterfaceId) -> Option<String>;
fn vec_name(&self) -> &'static str;
fn string_name(&self) -> &'static str;
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,
mutbl: bool,
ty: &Type,
lifetime: &'static str
);
fn print_borrowed_str(&mut self, lifetime: &'static str);
// Provided methods
fn std_feature(&self) -> bool { ... }
fn use_raw_strings(&self) -> bool { ... }
fn rustdoc(&mut self, docs: &Docs) { ... }
fn rustdoc_params(&mut self, docs: &[(String, Type)], header: &str) { ... }
fn print_signature(
&mut self,
func: &Function,
param_mode: TypeMode,
sig: &FnSig
) -> Vec<String> { ... }
fn print_docs_and_params(
&mut self,
func: &Function,
param_mode: TypeMode,
sig: &FnSig
) -> Vec<String> { ... }
fn print_results(&mut self, results: &Results, mode: TypeMode) { ... }
fn print_ty(&mut self, ty: &Type, mode: TypeMode) { ... }
fn print_optional_ty(&mut self, ty: Option<&Type>, mode: TypeMode) { ... }
fn type_path(&self, id: TypeId, owned: bool) -> String { ... }
fn print_tyid(&mut self, id: TypeId, mode: TypeMode) { ... }
fn print_list(&mut self, ty: &Type, mode: TypeMode) { ... }
fn print_rust_slice(&mut self, mutbl: bool, ty: &Type, lifetime: &'static str) { ... }
fn print_generics(&mut self, lifetime: Option<&str>) { ... }
fn int_repr(&mut self, repr: Int) { ... }
fn wasm_type(&mut self, ty: WasmType) { ... }
fn modes_of(&self, ty: TypeId) -> Vec<(String, TypeMode)> { ... }
fn write_name(&self, ty: &Type, out: &mut String) { ... }
fn write_optional_name(&self, ty: Option<&Type>, out: &mut String) { ... }
fn union_case_names(&self, union: &Union) -> Vec<String> { ... }
fn print_typedef_record(
&mut self,
id: TypeId,
record: &Record,
docs: &Docs,
derive_component: bool
) { ... }
fn print_typedef_tuple(&mut self, id: TypeId, tuple: &Tuple, docs: &Docs) { ... }
fn print_typedef_variant(
&mut self,
id: TypeId,
variant: &Variant,
docs: &Docs,
derive_component: bool
)
where Self: Sized { ... }
fn print_typedef_union(
&mut self,
id: TypeId,
union: &Union,
docs: &Docs,
derive_component: bool
)
where Self: Sized { ... }
fn print_rust_enum<'b>(
&mut self,
id: TypeId,
cases: impl IntoIterator<Item = (String, Option<String>, &'b Docs, Option<&'b Type>)> + Clone,
docs: &Docs,
derive_component: Option<&str>
)
where Self: Sized { ... }
fn print_rust_enum_debug<'b>(
&mut self,
id: TypeId,
mode: TypeMode,
name: &str,
cases: impl IntoIterator<Item = (String, Option<&'b Type>)>
)
where Self: Sized { ... }
fn print_typedef_option(&mut self, id: TypeId, payload: &Type, docs: &Docs) { ... }
fn print_typedef_result(&mut self, id: TypeId, result: &Result_, docs: &Docs) { ... }
fn print_typedef_enum(
&mut self,
id: TypeId,
name: &str,
enum_: &Enum,
docs: &Docs,
attrs: &[String],
case_attr: Box<dyn Fn(&EnumCase) -> String>
)
where Self: Sized { ... }
fn print_typedef_alias(&mut self, id: TypeId, ty: &Type, docs: &Docs) { ... }
fn print_type_list(&mut self, id: TypeId, ty: &Type, docs: &Docs) { ... }
fn param_name(&self, ty: TypeId) -> String { ... }
fn result_name(&self, 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 resolve(&self) -> &'a Resolve
fn path_to_interface(&self, interface: InterfaceId) -> Option<String>
sourcefn string_name(&self) -> &'static str
fn string_name(&self) -> &'static str
Return the fully-qualified name for the String type to use.
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, mutbl: bool, ty: &Type, lifetime: &'static str)
fn print_borrowed_str(&mut self, lifetime: &'static str)
Provided Methods§
sourcefn std_feature(&self) -> bool
fn std_feature(&self) -> bool
Return true iff the generator should qualify uses of std features with
#[cfg(feature = "std")] in its output.
sourcefn use_raw_strings(&self) -> bool
fn use_raw_strings(&self) -> bool
Return true iff the generator should use &[u8] instead of &str in bindings.
fn rustdoc(&mut self, docs: &Docs)
fn rustdoc_params(&mut self, docs: &[(String, Type)], header: &str)
fn print_signature( &mut self, func: &Function, param_mode: TypeMode, sig: &FnSig ) -> Vec<String>
fn print_docs_and_params( &mut self, func: &Function, param_mode: TypeMode, sig: &FnSig ) -> Vec<String>
fn print_results(&mut self, results: &Results, mode: TypeMode)
fn print_ty(&mut self, ty: &Type, mode: TypeMode)
fn print_optional_ty(&mut self, ty: Option<&Type>, mode: TypeMode)
fn type_path(&self, id: TypeId, owned: bool) -> String
fn print_tyid(&mut self, id: TypeId, mode: TypeMode)
fn print_list(&mut self, ty: &Type, mode: TypeMode)
fn print_rust_slice(&mut self, mutbl: bool, ty: &Type, lifetime: &'static str)
fn print_generics(&mut self, lifetime: Option<&str>)
fn int_repr(&mut self, repr: Int)
fn wasm_type(&mut self, ty: WasmType)
fn modes_of(&self, ty: TypeId) -> Vec<(String, TypeMode)>
sourcefn write_name(&self, ty: &Type, out: &mut String)
fn write_name(&self, ty: &Type, out: &mut String)
Writes the camel-cased ‘name’ of the passed type to out, as used to name union variants.
fn write_optional_name(&self, ty: Option<&Type>, out: &mut String)
sourcefn union_case_names(&self, union: &Union) -> Vec<String>
fn union_case_names(&self, union: &Union) -> Vec<String>
Returns the names for the cases of the passed union.