fn write_sandbox_memory_from_scratch(
		&mut self,
		ptr: u32,
		offset: u32,
		len: u32,
	) -> Result<(), sp_sandbox::HostError> {
		let offset = offset as usize;
		if offset > self.scratch_buf.len() {
			// Offset can't be larger than scratch buffer length.
			return Err(sp_sandbox::HostError);
		}

		// This can't panic since `offset <= ctx.scratch_buf.len()`.
		if self.scratch_buf[offset..].len() != len as usize {
			return Err(sp_sandbox::HostError);
		}
		self.charge_gas(
			RuntimeToken::WriteMemory(len),
		)?;

		let src = &self.scratch_buf[offset..];
		self.memory.set(ptr, src)?;

		Ok(())
	}
/// Write the given buffer to the designated location in the sandbox memory, consuming
/// an appropriate amount of gas.
///
/// Returns `Err` if one of the following conditions occurs:
///
/// - calculating the gas cost resulted in overflow.
/// - out of gas
/// - designated area is not within the bounds of the sandbox memory.
Write the given buffer to the designated location in the sandbox memory, consuming
an appropriate amount of gas.

Returns `Err` if one of the following conditions occurs.

calculating the gas cost resulted in overflow.
out of gas
designated area is not within the bounds of the sandbox memory.
Write the given buffer to the designated location in the sandbox memory consuming an appropriate amount of gas . Returns ` Err ` if one of the following conditions occurs . calculating the gas cost resulted in overflow . out of gas designated area is not within the bounds of the sandbox memory .
fn write_sandbox_memory_from_scratch(
		&mut self,
		ptr: u32,
		offset: u32,
		len: u32,
	) -> Result<(), sp_sandbox::HostError> {
		let offset = offset as usize;
		if offset > self.scratch_buf.len() {
			// Offset can't be larger than scratch buffer length.
			return Err(sp_sandbox::HostError);
		}
		// This can't panic since `offset <= ctx.scratch_buf.len()`.
		if self.scratch_buf[offset..].len() != len as usize {
			return Err(sp_sandbox::HostError);
		}
		self.charge_gas(
			RuntimeToken::WriteMemory(len),
		)?;
		let src = &self.scratch_buf[offset..];
		self.memory.set(ptr, src)?;
		Ok(())
	}
fn write_sandbox_memory_from_scratch ( & mut self , ptr : u32 , offset : u32 , len : u32 , ) -> Result < ( ) , sp_sandbox :: HostError > { let offset = offset as usize ; if offset > self . scratch_buf . len ( ) { // Offset can't be larger than scratch buffer length. return Err ( sp_sandbox :: HostError ) ; } // This can't panic since `offset <= ctx.scratch_buf.len()`. if self . scratch_buf [ offset .. ] . len ( ) != len as usize { return Err ( sp_sandbox :: HostError ) ; } self . charge_gas ( RuntimeToken :: WriteMemory ( len ) , ) ? ; let src = & self . scratch_buf [ offset .. ] ; self . memory . set ( ptr , src ) ? ; Ok ( ( ) ) }
Write the given buffer to the designated location in the sandbox memory, consuming
an appropriate amount of gas.
Write the given buffer to the designated location in the sandbox memory consuming an appropriate amount of gas .
&mut self
ptr
u32
offset
u32
len
u32
&mut self
ptr
u32
offset
u32
len
u32