Struct ink_lang_ir::Contract [−][src]
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]
ink_config: TokenStream2,
ink_module: TokenStream2
) -> Result<Self, Error>
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 intoir::Config
. - The
ink_module
token stream must properly decode intoir::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 specifyEnvironment
different from the default environment types.storage-alloc
: Iftrue
enables the dynamic storage allocator facilities and code generation of the ink! smart contract. Does incure some overhead. The default istrue
.as-dependency
: Iftrue
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 isfalse
.
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,