Struct ink_lang_ir::Contract[][src]

pub struct Contract { /* fields omitted */ }

An ink! contract definition consisting of the ink! configuration and module.

This is the root of any ink! smart contract definition. It contains every information accessible to the ink! smart contract macros. It is also used as the root source for the ink! code generation.

Example

#[ink::contract(/* optional ink! configurations */)]
mod my_contract {
    /* ink! and Rust definitions */
}

Implementations

impl Contract[src]

pub fn new(
    ink_config: TokenStream2,
    ink_module: TokenStream2
) -> Result<Self, Error>
[src]

Creates a new ink! contract from the given ink! configuration and module token streams.

The ink! macro should use this constructor in order to setup ink!.

Note

  • The ink_config token stream must properly decode into ir::Config.
  • The ink_module token stream must properly decode into ir::ItemMod.

Errors

Returns an error if the provided token stream cannot be decoded properly into a valid ink! configuration or ink! module respectively.

pub fn module(&self) -> &ItemMod[src]

Returns the ink! inline module definition.

Note

The ink! inline module definition is the module that comprises the whole ink! smart contract, e.g.:

#[ink::contract]
mod my_contract {
    // ... definitions
}

pub fn config(&self) -> &Config[src]

Returns the configuration of the ink! smart contract.

Note

The configuration is given via the #[ink::contract(config))] attribute macro annotation itself within the (config) part. The available fields are the following:

  • types: To specify Environment different from the default environment types.
  • storage-alloc: If true enables the dynamic storage allocator facilities and code generation of the ink! smart contract. Does incure some overhead. The default is true.
  • as-dependency: If true compiles this ink! smart contract always as if it was a dependency of another smart contract. This configuration is mainly needed for testing and the default is false.

Note that we might add more configuration fields in the future if necessary.

Auto Trait Implementations

impl RefUnwindSafe for Contract

impl !Send for Contract

impl !Sync for Contract

impl Unpin for Contract

impl UnwindSafe for Contract

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.