fn scan_imports<C: ImportSatisfyCheck>(&self) -> Result<Option<&MemoryType>, &'static str> {
		let module = self
			.module
			.as_ref()
			.expect("On entry to the function `module` can't be `None`; qed");

		let types = module.type_section().map(|ts| ts.types()).unwrap_or(&[]);
		let import_entries = module
			.import_section()
			.map(|is| is.entries())
			.unwrap_or(&[]);

		let mut imported_mem_type = None;

		for import in import_entries {
			if import.module() != "env" {
				// This import tries to import something from non-"env" module,
				// but all imports are located in "env" at the moment.
				return Err("module has imports from a non-'env' namespace");
			}

			let type_idx = match import.external() {
				&External::Function(ref type_idx) => type_idx,
				&External::Memory(ref memory_type) => {
					imported_mem_type = Some(memory_type);
					continue;
				}
				_ => continue,
			};

			let Type::Function(ref func_ty) = types
				.get(*type_idx as usize)
				.ok_or_else(|| "validation: import entry points to a non-existent type")?;

			// We disallow importing `ext_println` unless debug features are enabled,
			// which should only be allowed on a dev chain
			if !self.schedule.enable_println && import.field().as_bytes() == b"ext_println" {
				return Err("module imports `ext_println` but debug features disabled");
			}

			// We disallow importing `gas` function here since it is treated as implementation detail.
			if import.field().as_bytes() == b"gas"
				|| !C::can_satisfy(import.field().as_bytes(), func_ty)
			{
				return Err("module imports a non-existent function");
			}
		}
		Ok(imported_mem_type)
	}
/// Scan an import section if any.
///
/// This accomplishes two tasks:
///
/// - checks any imported function against defined host functions set, incl.
///   their signatures.
/// - if there is a memory import, returns it's descriptor
Scan an import section if any.
This accomplishes two tasks.

checks any imported function against defined host functions set, incl.
their signatures.
if there is a memory import, returns it's descriptor
Scan an import section if any . This accomplishes two tasks . checks any imported function against defined host functions set incl . their signatures . if there is a memory import returns it ' s descriptor
fn scan_imports<C: ImportSatisfyCheck>(&self) -> Result<Option<&MemoryType>, &'static str> {
		let module = self
			.module
			.as_ref()
			.expect("On entry to the function `module` can't be `None`; qed");
		let types = module.type_section().map(|ts| ts.types()).unwrap_or(&[]);
		let import_entries = module
			.import_section()
			.map(|is| is.entries())
			.unwrap_or(&[]);
		let mut imported_mem_type = None;
		for import in import_entries {
			if import.module() != "env" {
				// This import tries to import something from non-"env" module,
				// but all imports are located in "env" at the moment.
				return Err("module has imports from a non-'env' namespace");
			}
			let type_idx = match import.external() {
				&External::Function(ref type_idx) => type_idx,
				&External::Memory(ref memory_type) => {
					imported_mem_type = Some(memory_type);
					continue;
				}
				_ => continue,
			};
			let Type::Function(ref func_ty) = types
				.get(*type_idx as usize)
				.ok_or_else(|| "validation: import entry points to a non-existent type")?;
			// We disallow importing `ext_println` unless debug features are enabled,
			// which should only be allowed on a dev chain
			if !self.schedule.enable_println && import.field().as_bytes() == b"ext_println" {
				return Err("module imports `ext_println` but debug features disabled");
			}
			// We disallow importing `gas` function here since it is treated as implementation detail.
			if import.field().as_bytes() == b"gas"
				|| !C::can_satisfy(import.field().as_bytes(), func_ty)
			{
				return Err("module imports a non-existent function");
			}
		}
		Ok(imported_mem_type)
	}
fn scan_imports < C : ImportSatisfyCheck > ( & self ) -> Result < Option < & MemoryType > , & ' static str > { let module = self . module . as_ref ( ) . expect ( " " ) ; let types = module . type_section ( ) . map ( | ts | ts . types ( ) ) . unwrap_or ( & [ ] ) ; let import_entries = module . import_section ( ) . map ( | is | is . entries ( ) ) . unwrap_or ( & [ ] ) ; let mut imported_mem_type = None ; for import in import_entries { if import . module ( ) != " " { // This import tries to import something from non-"env" module, // but all imports are located in "env" at the moment. return Err ( " " ) ; } let type_idx = match import . external ( ) { & External :: Function ( ref type_idx ) => type_idx , & External :: Memory ( ref memory_type ) => { imported_mem_type = Some ( memory_type ) ; continue ; } _ => continue , } ; let Type :: Function ( ref func_ty ) = types . get ( * type_idx as usize ) . ok_or_else ( | | " " ) ? ; // We disallow importing `ext_println` unless debug features are enabled, // which should only be allowed on a dev chain if ! self . schedule . enable_println && import . field ( ) . as_bytes ( ) == b" " { return Err ( " " ) ; } // We disallow importing `gas` function here since it is treated as implementation detail. if import . field ( ) . as_bytes ( ) == b" " || ! C :: can_satisfy ( import . field ( ) . as_bytes ( ) , func_ty ) { return Err ( " " ) ; } } Ok ( imported_mem_type ) }
Scan an import section if any.
Scan an import section if any .
&self
&self