Struct Module

Source
pub struct Module { /* private fields */ }
Expand description

WebAssembly module

Implementations§

Source§

impl Module

Source

pub fn new(sections: Vec<Section>) -> Self

New module with sections

Source

pub fn into_sections(self) -> Vec<Section>

Destructure the module, yielding sections

Source

pub fn version(&self) -> u32

Version of module.

Source

pub fn sections(&self) -> &[Section]

Sections list. Each known section is optional and may appear at most once.

Examples found in repository?
examples/info.rs (line 15)
6fn main() {
7    let args = env::args().collect::<Vec<_>>();
8    if args.len() != 2 {
9        println!("Usage: {} somefile.wasm", args[0]);
10        return;
11    }
12
13    let module = sophon_wasm::deserialize_file(&args[1]).expect("Failed to load module");
14
15    println!("Module sections: {}", module.sections().len());
16
17    for section in module.sections() {
18        match *section {
19            Section::Import(ref import_section) => {
20                println!("  Imports: {}", import_section.entries().len());
21                import_section.entries().iter().map(|e| println!("    {}.{}", e.module(), e.field())).count();
22            },
23            Section::Export(ref exports_section) => {
24                println!("  Exports: {}", exports_section.entries().len());
25                exports_section.entries().iter().map(|e| println!("    {}", e.field())).count();
26            },            
27            Section::Function(ref function_section) => {
28                println!("  Functions: {}", function_section.entries().len());
29            },
30            Section::Type(ref type_section) => {
31                println!("  Types: {}", type_section.types().len());
32            },
33            Section::Global(ref globals_section) => {
34                println!("  Globals: {}", globals_section.entries().len());                
35            },
36            Section::Data(ref data_section) if data_section.entries().len() > 0 => {
37                let data = &data_section.entries()[0];
38                println!("  Data size: {}", data.value().len()); 
39            },
40            _ => {},
41        }
42    }
43}
Source

pub fn sections_mut(&mut self) -> &mut Vec<Section>

Sections list (mutable) Each known section is optional and may appear at most once.

Examples found in repository?
examples/inject.rs (line 37)
28fn main() {
29    let args = env::args().collect::<Vec<_>>();
30    if args.len() != 3 {
31        println!("Usage: {} input_file.wasm output_file.wasm", args[0]);
32        return;
33    }
34
35    let mut module = sophon_wasm::deserialize_file(&args[1]).unwrap();
36
37    for section in module.sections_mut() {
38        match section {
39            &mut elements::Section::Code(ref mut code_section) => {
40                for ref mut func_body in code_section.bodies_mut() {
41                    inject_nop(func_body.code_mut());
42                }
43            },
44            _ => { }
45        }
46    }
47
48    let mut build = builder::from_module(module);
49    let import_sig = build.push_signature(
50        builder::signature()
51            .param().i32()
52            .param().i32()
53            .return_type().i32()
54            .build_sig()
55    );
56    let build = build.import()
57        .module("env")
58        .field("log")
59        .external().func(import_sig)
60        .build();
61
62    sophon_wasm::serialize_to_file(&args[2], build.build()).unwrap();
63}
Source

pub fn code_section(&self) -> Option<&CodeSection>

Code section, if any.

Source

pub fn type_section(&self) -> Option<&TypeSection>

Types section, if any.

Examples found in repository?
examples/exports.rs (line 16)
11fn type_by_index(module: &Module, index: usize) -> FunctionType {
12
13    // Demand that function and type section exist. Otherwise, fail with a
14    // corresponding error.
15    let function_section = module.function_section().expect("No function section found");
16    let type_section = module.type_section().expect("No type section found");
17
18    // This counts the number of _function_ imports listed by the module, excluding
19    // the globals, since indexing for actual functions for `call` and `export` purposes
20    // includes both imported and own functions. So we actualy need the imported function count
21    // to resolve actual index of the given function in own functions list.
22    let import_section_len: usize = match module.import_section() {
23            Some(import) =>
24                import.entries().iter().filter(|entry| match entry.external() {
25                    &External::Function(_) => true,
26                    _ => false,
27                    }).count(),
28            None => 0,
29        };
30
31    // Substract the value queried in the previous step from the provided index
32    // to get own function index from which we can query type next.
33    let function_index_in_section = index - import_section_len;
34
35    // Query the own function given we have it's index
36    let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
37
38    // Finally, return function type (signature)
39    match type_section.types()[func_type_ref] {
40        Type::Function(ref func_type) => func_type.clone(),
41    }
42}
More examples
Hide additional examples
examples/invoke.rs (line 30)
9fn main() {
10    let args: Vec<_> = args().collect();
11    if args.len() < 3 {
12        println!("Usage: {} <wasm file> <exported func> [<arg>...]", args[0]);
13        return;
14    }
15    let func_name = &args[2];
16    let (_, program_args) = args.split_at(3);
17
18    // Intrepreter initialization.
19    let program = sophon_wasm::ProgramInstance::new();
20
21    let module = sophon_wasm::deserialize_file(&args[1]).expect("File to be deserialized");
22
23    // Extracts call arguments from command-line arguments
24    let execution_params = {
25        // Export section has an entry with a func_name with an index inside a module
26        let export_section = module.export_section().expect("No export section found");
27        // It's a section with function declarations (which are references to the type section entries)
28        let function_section = module.function_section().expect("No function section found");
29        // Type section stores function types which are referenced by function_section entries
30        let type_section = module.type_section().expect("No type section found");
31
32        // Given function name used to find export section entry which contains
33        // an `internal` field which points to the index in the function index space
34        let found_entry = export_section.entries().iter()
35            .find(|entry| func_name == entry.field()).expect(&format!("No export with name {} found", func_name));
36
37        // Function index in the function index space (internally-defined + imported)
38        let function_index: usize = match found_entry.internal() {
39            &Internal::Function(index) => index as usize,
40            _ => panic!("Founded export is not a function"),
41        };
42
43        // We need to count import section entries (functions only!) to subtract it from function_index
44        // and obtain the index within the function section
45        let import_section_len: usize = match module.import_section() {
46            Some(import) =>
47                import.entries().iter().filter(|entry| match entry.external() {
48                    &External::Function(_) => true,
49                    _ => false,
50                    }).count(),
51            None => 0,
52        };
53
54        // Calculates a function index within module's function section
55        let function_index_in_section = function_index - import_section_len;
56
57        // Getting a type reference from a function section entry
58        let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
59
60        // Use the reference to get an actual function type
61        let function_type: &FunctionType = match &type_section.types()[func_type_ref] {
62            &Type::Function(ref func_type) => func_type,
63        };
64
65        // Parses arguments and constructs runtime values in correspondence of their types
66        let args: Vec<RuntimeValue> = function_type.params().iter().enumerate().map(|(i, value)| match value {
67            &ValueType::I32 => RuntimeValue::I32(program_args[i].parse::<i32>().expect(&format!("Can't parse arg #{} as i32", program_args[i]))),
68            &ValueType::I64 => RuntimeValue::I64(program_args[i].parse::<i64>().expect(&format!("Can't parse arg #{} as i64", program_args[i]))),
69            &ValueType::F32 => RuntimeValue::F32(program_args[i].parse::<f32>().expect(&format!("Can't parse arg #{} as f32", program_args[i]))),
70            &ValueType::F64 => RuntimeValue::F64(program_args[i].parse::<f64>().expect(&format!("Can't parse arg #{} as f64", program_args[i]))),
71        }).collect();
72
73        interpreter::ExecutionParams::from(args)
74    };
75
76    // Intialize deserialized module. It adds module into It expects 3 parameters:
77    // - a name for the module
78    // - a module declaration
79    // - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
80    // This test shows how to implement native module https://github.com/NikVolf/sophon-wasm/blob/master/src/interpreter/tests/basics.rs#L197
81    let module = program.add_module("main", module, None).expect("Failed to initialize module");
82
83    println!("Result: {:?}", module.execute_export(func_name, execution_params).expect(""));
84}
Source

pub fn import_section(&self) -> Option<&ImportSection>

Imports section, if any.

Examples found in repository?
examples/exports.rs (line 22)
11fn type_by_index(module: &Module, index: usize) -> FunctionType {
12
13    // Demand that function and type section exist. Otherwise, fail with a
14    // corresponding error.
15    let function_section = module.function_section().expect("No function section found");
16    let type_section = module.type_section().expect("No type section found");
17
18    // This counts the number of _function_ imports listed by the module, excluding
19    // the globals, since indexing for actual functions for `call` and `export` purposes
20    // includes both imported and own functions. So we actualy need the imported function count
21    // to resolve actual index of the given function in own functions list.
22    let import_section_len: usize = match module.import_section() {
23            Some(import) =>
24                import.entries().iter().filter(|entry| match entry.external() {
25                    &External::Function(_) => true,
26                    _ => false,
27                    }).count(),
28            None => 0,
29        };
30
31    // Substract the value queried in the previous step from the provided index
32    // to get own function index from which we can query type next.
33    let function_index_in_section = index - import_section_len;
34
35    // Query the own function given we have it's index
36    let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
37
38    // Finally, return function type (signature)
39    match type_section.types()[func_type_ref] {
40        Type::Function(ref func_type) => func_type.clone(),
41    }
42}
More examples
Hide additional examples
examples/invoke.rs (line 45)
9fn main() {
10    let args: Vec<_> = args().collect();
11    if args.len() < 3 {
12        println!("Usage: {} <wasm file> <exported func> [<arg>...]", args[0]);
13        return;
14    }
15    let func_name = &args[2];
16    let (_, program_args) = args.split_at(3);
17
18    // Intrepreter initialization.
19    let program = sophon_wasm::ProgramInstance::new();
20
21    let module = sophon_wasm::deserialize_file(&args[1]).expect("File to be deserialized");
22
23    // Extracts call arguments from command-line arguments
24    let execution_params = {
25        // Export section has an entry with a func_name with an index inside a module
26        let export_section = module.export_section().expect("No export section found");
27        // It's a section with function declarations (which are references to the type section entries)
28        let function_section = module.function_section().expect("No function section found");
29        // Type section stores function types which are referenced by function_section entries
30        let type_section = module.type_section().expect("No type section found");
31
32        // Given function name used to find export section entry which contains
33        // an `internal` field which points to the index in the function index space
34        let found_entry = export_section.entries().iter()
35            .find(|entry| func_name == entry.field()).expect(&format!("No export with name {} found", func_name));
36
37        // Function index in the function index space (internally-defined + imported)
38        let function_index: usize = match found_entry.internal() {
39            &Internal::Function(index) => index as usize,
40            _ => panic!("Founded export is not a function"),
41        };
42
43        // We need to count import section entries (functions only!) to subtract it from function_index
44        // and obtain the index within the function section
45        let import_section_len: usize = match module.import_section() {
46            Some(import) =>
47                import.entries().iter().filter(|entry| match entry.external() {
48                    &External::Function(_) => true,
49                    _ => false,
50                    }).count(),
51            None => 0,
52        };
53
54        // Calculates a function index within module's function section
55        let function_index_in_section = function_index - import_section_len;
56
57        // Getting a type reference from a function section entry
58        let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
59
60        // Use the reference to get an actual function type
61        let function_type: &FunctionType = match &type_section.types()[func_type_ref] {
62            &Type::Function(ref func_type) => func_type,
63        };
64
65        // Parses arguments and constructs runtime values in correspondence of their types
66        let args: Vec<RuntimeValue> = function_type.params().iter().enumerate().map(|(i, value)| match value {
67            &ValueType::I32 => RuntimeValue::I32(program_args[i].parse::<i32>().expect(&format!("Can't parse arg #{} as i32", program_args[i]))),
68            &ValueType::I64 => RuntimeValue::I64(program_args[i].parse::<i64>().expect(&format!("Can't parse arg #{} as i64", program_args[i]))),
69            &ValueType::F32 => RuntimeValue::F32(program_args[i].parse::<f32>().expect(&format!("Can't parse arg #{} as f32", program_args[i]))),
70            &ValueType::F64 => RuntimeValue::F64(program_args[i].parse::<f64>().expect(&format!("Can't parse arg #{} as f64", program_args[i]))),
71        }).collect();
72
73        interpreter::ExecutionParams::from(args)
74    };
75
76    // Intialize deserialized module. It adds module into It expects 3 parameters:
77    // - a name for the module
78    // - a module declaration
79    // - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
80    // This test shows how to implement native module https://github.com/NikVolf/sophon-wasm/blob/master/src/interpreter/tests/basics.rs#L197
81    let module = program.add_module("main", module, None).expect("Failed to initialize module");
82
83    println!("Result: {:?}", module.execute_export(func_name, execution_params).expect(""));
84}
Source

pub fn global_section(&self) -> Option<&GlobalSection>

Globals section, if any.

Source

pub fn export_section(&self) -> Option<&ExportSection>

Exports section, if any.

Examples found in repository?
examples/exports.rs (line 62)
44fn main() {
45
46    // Example executable takes one argument which must
47    // refernce the existing file with a valid wasm module
48    let args: Vec<_> = args().collect();
49    if args.len() < 2 {
50        println!("Prints export function names with and their types");
51        println!("Usage: {} <wasm file>", args[0]);
52        return;
53    }
54
55    // Here we load module using dedicated for this purpose
56    // `deserialize_file` function (which works only with modules)
57    let module = sophon_wasm::deserialize_file(&args[1]).expect("File to be deserialized");
58
59    // Query the export section from the loaded module. Note that not every
60    // wasm module obliged to contain export section. So in case there is no
61    // any export section, we panic with the corresponding error.
62    let export_section = module.export_section().expect("No export section found");
63
64    // Process all exports, leaving only those which reference the internal function
65    // of the wasm module
66    let exports: Vec<String> = export_section.entries().iter()
67        .filter_map(|entry|
68            // This is match on export variant, which can be function, global,table or memory
69            // We are interested only in functions for an example
70            match *entry.internal() {
71                // Return function export name (return by field() function and it's index)
72                Internal::Function(index) => Some((entry.field(), index as usize)),
73                _ => None
74            })
75        // Another map to resolve function signature index given it's internal index and return
76        // the printable string of the export
77        .map(|(field, index)| format!("{:}: {:?}", field, type_by_index(&module, index).params())).collect();
78
79    // Print the result
80    for export in exports {
81        println!("{:}", export);
82    }
83}
More examples
Hide additional examples
examples/invoke.rs (line 26)
9fn main() {
10    let args: Vec<_> = args().collect();
11    if args.len() < 3 {
12        println!("Usage: {} <wasm file> <exported func> [<arg>...]", args[0]);
13        return;
14    }
15    let func_name = &args[2];
16    let (_, program_args) = args.split_at(3);
17
18    // Intrepreter initialization.
19    let program = sophon_wasm::ProgramInstance::new();
20
21    let module = sophon_wasm::deserialize_file(&args[1]).expect("File to be deserialized");
22
23    // Extracts call arguments from command-line arguments
24    let execution_params = {
25        // Export section has an entry with a func_name with an index inside a module
26        let export_section = module.export_section().expect("No export section found");
27        // It's a section with function declarations (which are references to the type section entries)
28        let function_section = module.function_section().expect("No function section found");
29        // Type section stores function types which are referenced by function_section entries
30        let type_section = module.type_section().expect("No type section found");
31
32        // Given function name used to find export section entry which contains
33        // an `internal` field which points to the index in the function index space
34        let found_entry = export_section.entries().iter()
35            .find(|entry| func_name == entry.field()).expect(&format!("No export with name {} found", func_name));
36
37        // Function index in the function index space (internally-defined + imported)
38        let function_index: usize = match found_entry.internal() {
39            &Internal::Function(index) => index as usize,
40            _ => panic!("Founded export is not a function"),
41        };
42
43        // We need to count import section entries (functions only!) to subtract it from function_index
44        // and obtain the index within the function section
45        let import_section_len: usize = match module.import_section() {
46            Some(import) =>
47                import.entries().iter().filter(|entry| match entry.external() {
48                    &External::Function(_) => true,
49                    _ => false,
50                    }).count(),
51            None => 0,
52        };
53
54        // Calculates a function index within module's function section
55        let function_index_in_section = function_index - import_section_len;
56
57        // Getting a type reference from a function section entry
58        let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
59
60        // Use the reference to get an actual function type
61        let function_type: &FunctionType = match &type_section.types()[func_type_ref] {
62            &Type::Function(ref func_type) => func_type,
63        };
64
65        // Parses arguments and constructs runtime values in correspondence of their types
66        let args: Vec<RuntimeValue> = function_type.params().iter().enumerate().map(|(i, value)| match value {
67            &ValueType::I32 => RuntimeValue::I32(program_args[i].parse::<i32>().expect(&format!("Can't parse arg #{} as i32", program_args[i]))),
68            &ValueType::I64 => RuntimeValue::I64(program_args[i].parse::<i64>().expect(&format!("Can't parse arg #{} as i64", program_args[i]))),
69            &ValueType::F32 => RuntimeValue::F32(program_args[i].parse::<f32>().expect(&format!("Can't parse arg #{} as f32", program_args[i]))),
70            &ValueType::F64 => RuntimeValue::F64(program_args[i].parse::<f64>().expect(&format!("Can't parse arg #{} as f64", program_args[i]))),
71        }).collect();
72
73        interpreter::ExecutionParams::from(args)
74    };
75
76    // Intialize deserialized module. It adds module into It expects 3 parameters:
77    // - a name for the module
78    // - a module declaration
79    // - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
80    // This test shows how to implement native module https://github.com/NikVolf/sophon-wasm/blob/master/src/interpreter/tests/basics.rs#L197
81    let module = program.add_module("main", module, None).expect("Failed to initialize module");
82
83    println!("Result: {:?}", module.execute_export(func_name, execution_params).expect(""));
84}
Source

pub fn table_section(&self) -> Option<&TableSection>

Table section, if any.

Source

pub fn data_section(&self) -> Option<&DataSection>

Data section, if any.

Examples found in repository?
examples/data.rs (line 25)
8fn main() {
9
10    // Example executable takes one argument which must
11    // refernce the existing file with a valid wasm module
12    let args = env::args().collect::<Vec<_>>();
13    if args.len() != 2 {
14        println!("Usage: {} somefile.wasm", args[0]);
15        return;
16    }
17
18    // Here we load module using dedicated for this purpose
19    // `deserialize_file` function (which works only with modules)
20    let module = sophon_wasm::deserialize_file(&args[1]).expect("Failed to load module");
21
22    // We query module for data section. Note that not every valid
23    // wasm module must contain a data section. So in case the provided
24    // module does not contain data section, we panic with an error
25    let data_section = module.data_section().expect("no data section in module");
26
27    // Printing the total count of data segments
28    println!("Data segments: {}", data_section.entries().len());
29
30    let mut index = 0;
31    for entry in data_section.entries() {
32        // Printing the details info of each data segment
33        // see `elements::DataSegment` for more properties
34        // you can query
35        println!("  Entry #{}", index);
36
37        // This shows the initialization member of data segment
38        // (expression which must resolve in the linear memory location).
39        println!("    init: {}", entry.offset().code()[0]);
40
41        // This shows the total length of the data segment in bytes.
42        println!("    size: {}", entry.value().len());
43
44        index += 1;
45    }
46}
Source

pub fn elements_section(&self) -> Option<&ElementSection>

Element section, if any.

Source

pub fn memory_section(&self) -> Option<&MemorySection>

Memory section, if any.

Source

pub fn function_section(&self) -> Option<&FunctionSection>

Functions signatures section, if any.

Examples found in repository?
examples/exports.rs (line 15)
11fn type_by_index(module: &Module, index: usize) -> FunctionType {
12
13    // Demand that function and type section exist. Otherwise, fail with a
14    // corresponding error.
15    let function_section = module.function_section().expect("No function section found");
16    let type_section = module.type_section().expect("No type section found");
17
18    // This counts the number of _function_ imports listed by the module, excluding
19    // the globals, since indexing for actual functions for `call` and `export` purposes
20    // includes both imported and own functions. So we actualy need the imported function count
21    // to resolve actual index of the given function in own functions list.
22    let import_section_len: usize = match module.import_section() {
23            Some(import) =>
24                import.entries().iter().filter(|entry| match entry.external() {
25                    &External::Function(_) => true,
26                    _ => false,
27                    }).count(),
28            None => 0,
29        };
30
31    // Substract the value queried in the previous step from the provided index
32    // to get own function index from which we can query type next.
33    let function_index_in_section = index - import_section_len;
34
35    // Query the own function given we have it's index
36    let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
37
38    // Finally, return function type (signature)
39    match type_section.types()[func_type_ref] {
40        Type::Function(ref func_type) => func_type.clone(),
41    }
42}
More examples
Hide additional examples
examples/invoke.rs (line 28)
9fn main() {
10    let args: Vec<_> = args().collect();
11    if args.len() < 3 {
12        println!("Usage: {} <wasm file> <exported func> [<arg>...]", args[0]);
13        return;
14    }
15    let func_name = &args[2];
16    let (_, program_args) = args.split_at(3);
17
18    // Intrepreter initialization.
19    let program = sophon_wasm::ProgramInstance::new();
20
21    let module = sophon_wasm::deserialize_file(&args[1]).expect("File to be deserialized");
22
23    // Extracts call arguments from command-line arguments
24    let execution_params = {
25        // Export section has an entry with a func_name with an index inside a module
26        let export_section = module.export_section().expect("No export section found");
27        // It's a section with function declarations (which are references to the type section entries)
28        let function_section = module.function_section().expect("No function section found");
29        // Type section stores function types which are referenced by function_section entries
30        let type_section = module.type_section().expect("No type section found");
31
32        // Given function name used to find export section entry which contains
33        // an `internal` field which points to the index in the function index space
34        let found_entry = export_section.entries().iter()
35            .find(|entry| func_name == entry.field()).expect(&format!("No export with name {} found", func_name));
36
37        // Function index in the function index space (internally-defined + imported)
38        let function_index: usize = match found_entry.internal() {
39            &Internal::Function(index) => index as usize,
40            _ => panic!("Founded export is not a function"),
41        };
42
43        // We need to count import section entries (functions only!) to subtract it from function_index
44        // and obtain the index within the function section
45        let import_section_len: usize = match module.import_section() {
46            Some(import) =>
47                import.entries().iter().filter(|entry| match entry.external() {
48                    &External::Function(_) => true,
49                    _ => false,
50                    }).count(),
51            None => 0,
52        };
53
54        // Calculates a function index within module's function section
55        let function_index_in_section = function_index - import_section_len;
56
57        // Getting a type reference from a function section entry
58        let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
59
60        // Use the reference to get an actual function type
61        let function_type: &FunctionType = match &type_section.types()[func_type_ref] {
62            &Type::Function(ref func_type) => func_type,
63        };
64
65        // Parses arguments and constructs runtime values in correspondence of their types
66        let args: Vec<RuntimeValue> = function_type.params().iter().enumerate().map(|(i, value)| match value {
67            &ValueType::I32 => RuntimeValue::I32(program_args[i].parse::<i32>().expect(&format!("Can't parse arg #{} as i32", program_args[i]))),
68            &ValueType::I64 => RuntimeValue::I64(program_args[i].parse::<i64>().expect(&format!("Can't parse arg #{} as i64", program_args[i]))),
69            &ValueType::F32 => RuntimeValue::F32(program_args[i].parse::<f32>().expect(&format!("Can't parse arg #{} as f32", program_args[i]))),
70            &ValueType::F64 => RuntimeValue::F64(program_args[i].parse::<f64>().expect(&format!("Can't parse arg #{} as f64", program_args[i]))),
71        }).collect();
72
73        interpreter::ExecutionParams::from(args)
74    };
75
76    // Intialize deserialized module. It adds module into It expects 3 parameters:
77    // - a name for the module
78    // - a module declaration
79    // - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
80    // This test shows how to implement native module https://github.com/NikVolf/sophon-wasm/blob/master/src/interpreter/tests/basics.rs#L197
81    let module = program.add_module("main", module, None).expect("Failed to initialize module");
82
83    println!("Result: {:?}", module.execute_export(func_name, execution_params).expect(""));
84}
Source

pub fn start_section(&self) -> Option<u32>

Start section, if any.

Trait Implementations§

Source§

impl Clone for Module

Source§

fn clone(&self) -> Module

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Module

Source§

fn default() -> Self

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

impl Deserialize for Module

Source§

type Error = Error

Serialization error produced by deserialization routine.
Source§

fn deserialize<R: Read>(reader: &mut R) -> Result<Self, Self::Error>

Deserialize type from serial i/o
Source§

impl Serialize for Module

Source§

type Error = Error

Serialization error produced by serialization routine.
Source§

fn serialize<W: Write>(self, w: &mut W) -> Result<(), Self::Error>

Serialize type to serial i/o

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Erased for T