Struct Builder

Source
pub struct Builder { /* private fields */ }

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Source

pub fn input_bindgen_file<T: AsRef<Path>>( self, input_bindgen_file: T, ) -> Builder

Add an input .rs file(such as generated from bindgen) to generate binding.

Source

pub fn input_extern_file<T: AsRef<Path>>(self, input_extern_file: T) -> Builder

Add an input .rs file for collect extern methods to C# binding.

Source

pub fn method_filter( self, method_filter: fn(method_name: String) -> bool, ) -> Builder

Filter generate method callback, default is !x.starts_with('_')

Source

pub fn always_included_types<I, S>(self, always_included_types: I) -> Builder
where I: IntoIterator<Item = S>, S: ToString,

Adds a list of types that will always be considered to be included in the generated bindings, even if not part of any function signature

Source

pub fn rust_method_type_path<T: Into<String>>( self, rust_method_type_path: T, ) -> Builder

add original extern call type prefix to rust wrapper, return {rust_method_type_path}::foo()

Source

pub fn rust_method_prefix<T: Into<String>>( self, rust_method_prefix: T, ) -> Builder

add method prefix to rust wrapper, default is csbindgen_ pub extern "C" fn {rust_method_prefix}foo()

Source

pub fn rust_file_header<T: Into<String>>(self, rust_file_header: T) -> Builder

add file header string to rust wrapper, mod lz4;, use super::lz4;

Source

pub fn csharp_namespace<T: Into<String>>(self, csharp_namespace: T) -> Builder

configure C# file namespace(default is CsBindgen), “namespace {csharp_namespace}”

Source

pub fn csharp_import_namespace<T: Into<String>>( self, csharp_namespace: T, ) -> Builder

configure C# extra import namespace, “using {csharp_namespace};”

Source

pub fn csharp_class_name<T: Into<String>>(self, csharp_class_name: T) -> Builder

configure C# class name(default is NativeMethods), public static unsafe partial class {csharp_class_name}

Source

pub fn csharp_dll_name<T: Into<String>>(self, csharp_dll_name: T) -> Builder

configure C# load dll name, [DllImport({csharp_dll_name})]

Source

pub fn csharp_disable_emit_dll_name( self, csharp_disable_emit_dll_name: bool, ) -> Builder

configure don’t emit __DllName

Source

pub fn csharp_entry_point_prefix<T: Into<String>>( self, csharp_entry_point_prefix: T, ) -> Builder

configure C# DllImport EntryPoint prefix, [DllImport(, EntryPoint ="{csharp_entry_point_prefix}foo")]

Source

pub fn csharp_method_prefix<T: Into<String>>( self, csharp_method_prefix: T, ) -> Builder

configure C# calling method name prefix, public static extern void {csharp_method_prefix}foo()

Source

pub fn csharp_class_accessibility<T: Into<String>>( self, csharp_class_accessibility: T, ) -> Builder

configure C# class accessibility, default is internal {csharp_class_accessibility} static unsafe partial class NativeMethods

Source

pub fn csharp_dll_name_if<T: Into<String>>( self, if_symbol: T, if_dll_name: T, ) -> Builder

configure add C# dll name if directive, #if {if_symbol} __DllName = {if_dll_name}

Source

pub fn csharp_use_function_pointer( self, csharp_use_function_pointer: bool, ) -> Builder

configure C# generate function pointer as delegate* or Func/Action, default is true(generate delegate*)

Source

pub fn csharp_use_nint_types(self, csharp_use_nint_types: bool) -> Builder

configure C# usage of nint/nuint in place of System.IntPtr/System.UIntPtr, default is true (use nint/nuint)

Source

pub fn csharp_generate_const(self, csharp_generate_const: bool) -> Builder

👎Deprecated: User csharp_generate_const_filter instead

configure C# generate const, default is false equivalent to csharp_generate_const_filter(|_| csharp_generate_const)

Source

pub fn csharp_generate_const_filter( self, csharp_generate_const_filter: fn(const_name: &str) -> bool, ) -> Builder

configure C# generate const filter, default |_| false

Source

pub fn csharp_type_rename( self, csharp_type_rename: fn(rust_type_name: String) -> String, ) -> Builder

configure the mappings that C# type name from rust original type name, default |x| x

Source

pub fn csharp_file_header<T: Into<String>>( self, csharp_file_header: T, ) -> Builder

configure the additional header for the generated C# code.

configure the additional footer for the generated C# code.

Source

pub fn generate_csharp_file<P: AsRef<Path>>( &self, csharp_output_path: P, ) -> Result<(), Box<dyn Error>>

Source

pub fn generate_to_file<P: AsRef<Path>>( &self, rust_output_path: P, csharp_output_path: P, ) -> Result<(), Box<dyn Error>>

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.