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 ownership(&self) -> Ownership;
fn push_vec_name(&mut self);
fn push_string_name(&mut self);
fn is_exported_resource(&self, ty: TypeId) -> bool;
fn mark_resource_owned(&mut self, resource: TypeId);
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,
mode: TypeMode
);
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 type_path_with_name(&self, id: TypeId, name: String) -> 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,
mode: TypeMode
) { ... }
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 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_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 push_vec_name(&mut self)
fn push_vec_name(&mut self)
Pushes the name of the Vec
type to use.
sourcefn push_string_name(&mut self)
fn push_string_name(&mut self)
Pushes the name of the String
type to use.
fn is_exported_resource(&self, ty: TypeId) -> bool
fn mark_resource_owned(&mut self, resource: TypeId)
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, mode: TypeMode )
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.