Struct ink_lang_ir::Selector [−][src]
pub struct Selector { /* fields omitted */ }
Expand description
The selector of an ink! dispatchable.
Note
This is equal to the first four bytes of the SHA-3 hash of a function’s name.
Implementations
Computes the BLAKE-2 256-bit based selector from the given input bytes.
Note
trait_prefix
isNone
when computing the selector of ink! constructors and messages in inherent implementation blocks.trait_prefix
isSome
when computing the selector of ink! constructors and messages in trait implementation blocks. In this case thenamespace
is either the full path of the trait definition gained by Rust’smodule_path!
macro by default or it is customized by manual application of the#[ink(namespace = "my_namespace")]
ink! attribute. In the examplemy_namespace
concatenated with::
and the identifier of the trait definition would then be part of the providedtrait_prefix
parameter.fn_ident
refers to the ink! constructor or message identifier.
Inherent Implementation Blocks
For inherent implementation blocks, when trait_prefix
is None
the composed
selector is computed as follows:
- Apply
BLAKE2
256-bit hashH
on the bytes of the ASCII representation of thefn_ident
identifier. - The first 4 bytes of
H
make up the selector.
Trait Implementation Blocks
For trait implementation blocks, when trait_prefix
is
Some((namespace, trait_ident))
the composed selector is computed as follows:
- Compute the ASCII byte representation of
fn_ident
and call itF
. - Compute the ASCII byte representation of
namespace
and call itN
. - Compute the ASCII byte representation of
trait_ident
and call itT
. - Concatenate
N
,T
andF
using::
as separator and call itC
. - Apply the
BLAKE2
256-bit hashH
ofC
. - The first 4 bytes of
H
make up the selector.
Returns the big-endian u32
representation of the selector bytes.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Selector
impl UnwindSafe for Selector
Blanket Implementations
Mutably borrows from an owned value. Read more