Skip to main content

CodeExt

Trait CodeExt 

Source
pub trait CodeExt {
    // Required methods
    fn code_deploy(
        &mut self,
        method_context: MethodContext,
        contract: Address,
        code: &VariableBytes<'_, MAX_CODE_SIZE>,
    ) -> Result<Address, ContractError>;
    fn code_store(
        &mut self,
        method_context: MethodContext,
        contract: Address,
        contract_code: &Address,
        new_code: &VariableBytes<'_, MAX_CODE_SIZE>,
    ) -> Result<(), ContractError>;
    fn code_read<'code>(
        &self,
        contract: Address,
        contract_code: &Address,
        code: &mut impl OutputArg<VariableBytes<'code, MAX_CODE_SIZE>>,
    ) -> Result<(), ContractError>;
}
Expand description

Extension trait that provides helper methods for calling Code’s methods on Env for convenience purposes

Required Methods§

Source

fn code_deploy( &mut self, method_context: MethodContext, contract: Address, code: &VariableBytes<'_, MAX_CODE_SIZE>, ) -> Result<Address, ContractError>

Deploy a new contract with specified code

Source

fn code_store( &mut self, method_context: MethodContext, contract: Address, contract_code: &Address, new_code: &VariableBytes<'_, MAX_CODE_SIZE>, ) -> Result<(), ContractError>

Store contact’s code overriding previous code that might have been there.

Updates can only be done by the contract itself with direct calls.

Source

fn code_read<'code>( &self, contract: Address, contract_code: &Address, code: &mut impl OutputArg<VariableBytes<'code, MAX_CODE_SIZE>>, ) -> Result<(), ContractError>

Read contract’s code

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CodeExt for Env<'_>

Source§

fn code_deploy( &mut self, method_context: MethodContext, contract: Address, code: &VariableBytes<'_, MAX_CODE_SIZE>, ) -> Result<Address, ContractError>

Source§

fn code_store( &mut self, method_context: MethodContext, contract: Address, contract_code: &Address, new_code: &VariableBytes<'_, MAX_CODE_SIZE>, ) -> Result<(), ContractError>

Source§

fn code_read<'code>( &self, contract: Address, contract_code: &Address, code: &mut impl OutputArg<VariableBytes<'code, MAX_CODE_SIZE>>, ) -> Result<(), ContractError>

Implementors§