pub struct GearApi(/* private fields */);
Expand description
The API instance contains methods to access the node.
Implementations§
source§impl GearApi
impl GearApi
sourcepub async fn original_code_at(
&self,
code_id: CodeId,
at_block_hash: Option<H256>,
) -> Result<Vec<u8>>
pub async fn original_code_at( &self, code_id: CodeId, at_block_hash: Option<H256>, ) -> Result<Vec<u8>>
Returns original wasm code for the given code_id
at specified
at_block_hash
.
sourcepub async fn program_at(
&self,
program_id: ProgramId,
at_block_hash: Option<H256>,
) -> Result<ActiveProgram<u32>>
pub async fn program_at( &self, program_id: ProgramId, at_block_hash: Option<H256>, ) -> Result<ActiveProgram<u32>>
Returns ActiveProgram
for the given program_id
at specified
at_block_hash
.
sourcepub async fn transfer_keep_alive(
&self,
destination: ProgramId,
value: u128,
) -> Result<H256>
pub async fn transfer_keep_alive( &self, destination: ProgramId, value: u128, ) -> Result<H256>
Transfer value
to destination
’s account.
Sends the
pallet_balances::transfer
extrinsic.
This function returns a hash of the block with the transfer transaction.
sourcepub async fn transfer_allow_death(
&self,
destination: ProgramId,
value: u128,
) -> Result<H256>
pub async fn transfer_allow_death( &self, destination: ProgramId, value: u128, ) -> Result<H256>
Transfer value
to destination
’s account.
Sends the
pallet_balances::transfer
extrinsic.
This function returns a hash of the block with the transfer transaction.
sourcepub async fn transfer_all(
&self,
destination: ProgramId,
keep_alive: bool,
) -> Result<H256>
pub async fn transfer_all( &self, destination: ProgramId, keep_alive: bool, ) -> Result<H256>
Transfer value
to destination
’s account.
Sends the
pallet_balances::transfer
extrinsic.
This function returns a hash of the block with the transfer transaction.
sourcepub async fn create_program_bytes(
&self,
code_id: CodeId,
salt: impl AsRef<[u8]>,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, ProgramId, H256)>
pub async fn create_program_bytes( &self, code_id: CodeId, salt: impl AsRef<[u8]>, payload: impl AsRef<[u8]>, gas_limit: u64, value: u128, ) -> Result<(MessageId, ProgramId, H256)>
Create a new program from a previously uploaded code identified by
CodeId
and
initialize it with a byte slice payload
.
Sends the
pallet_gear::create_program
extrinsic.
Parameters:
code_id
is the code identifier that can be obtained by calling theupload_code
function;salt
is the arbitrary data needed to generate an address for a new program (control of salt uniqueness is entirely on the function caller’s side);payload
vector contains data to be processed in theinit
function of the newly deployed “child” program;gas_limit
is the maximum gas amount allowed to spend for the program creation and initialization;value
to be transferred to the program’s account during initialization.
This function returns a tuple with an init message identifier, newly created program identifier, and a hash of the block with the message enqueuing transaction.
§See also
create_program
function initializes a newly created program with an encoded payload.create_program_bytes_batch
function creates a batch of programs and initializes them.upload_code
function uploads a code and returns its identifier.upload_program_bytes
function uploads a new program and initialize it.
sourcepub async fn create_program_bytes_batch(
&self,
args: impl IntoIterator<Item = (CodeId, impl AsRef<[u8]>, impl AsRef<[u8]>, u64, u128)>,
) -> Result<(Vec<Result<(MessageId, ProgramId)>>, H256)>
pub async fn create_program_bytes_batch( &self, args: impl IntoIterator<Item = (CodeId, impl AsRef<[u8]>, impl AsRef<[u8]>, u64, u128)>, ) -> Result<(Vec<Result<(MessageId, ProgramId)>>, H256)>
Create a batch of programs.
A batch is a set of programs to be created within one function call.
Every entry of the args
iterator is a tuple of parameters used in the
create_program_bytes
function. It is
useful when deploying a multi-program dApp.
sourcepub async fn create_program(
&self,
code_id: CodeId,
salt: impl AsRef<[u8]>,
payload: impl Encode,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, ProgramId, H256)>
pub async fn create_program( &self, code_id: CodeId, salt: impl AsRef<[u8]>, payload: impl Encode, gas_limit: u64, value: u128, ) -> Result<(MessageId, ProgramId, H256)>
Same as create_program_bytes
, but
initializes a newly created program with an encoded payload
.
§See also
upload_code
function uploads a code and returns its identifier.upload_program
function uploads a new program and initialize it.
sourcepub async fn migrate_program(
&self,
src_program_id: ProgramId,
src_block_hash: Option<H256>,
dest_node_api: &GearApi,
) -> Result<ProgramId>
pub async fn migrate_program( &self, src_program_id: ProgramId, src_block_hash: Option<H256>, dest_node_api: &GearApi, ) -> Result<ProgramId>
Migrates an active program identified by src_program_id
onto another
node identified by dest_node_api
and returns the migrated program
identifier. All source program data is taken at the time of
src_block_hash
if it is specified or the most recent one.
sourcepub async fn get_program_pages_data_at(
&self,
program_id: ProgramId,
block_hash: Option<H256>,
) -> Result<BTreeMap<GearPage, PageBuf>>
pub async fn get_program_pages_data_at( &self, program_id: ProgramId, block_hash: Option<H256>, ) -> Result<BTreeMap<GearPage, PageBuf>>
Get all pages with their data for program at specified block.
sourcepub async fn get_program_specified_pages_data_at(
&self,
program_id: ProgramId,
pages: impl Iterator<Item = GearPage>,
block_hash: Option<H256>,
) -> Result<BTreeMap<GearPage, PageBuf>>
pub async fn get_program_specified_pages_data_at( &self, program_id: ProgramId, pages: impl Iterator<Item = GearPage>, block_hash: Option<H256>, ) -> Result<BTreeMap<GearPage, PageBuf>>
Get specified pages with their data for program at specified block.
sourcepub async fn save_program_memory_dump_at<P: AsRef<Path>>(
&self,
program_id: ProgramId,
block_hash: Option<H256>,
file_path: P,
) -> Result
pub async fn save_program_memory_dump_at<P: AsRef<Path>>( &self, program_id: ProgramId, block_hash: Option<H256>, file_path: P, ) -> Result
Save program (identified by program_id
) memory dump to the file for
further restoring in gclient/gtest. Program memory dumped at the
time of block_hash
if presented or the most recent block.
sourcepub async fn replace_program_memory<P: AsRef<Path>>(
&self,
program_id: ProgramId,
file_path: P,
) -> Result
pub async fn replace_program_memory<P: AsRef<Path>>( &self, program_id: ProgramId, file_path: P, ) -> Result
Replace entire program memory with one saved earlier in gclient/gtest
sourcepub async fn claim_value(&self, message_id: MessageId) -> Result<(u128, H256)>
pub async fn claim_value(&self, message_id: MessageId) -> Result<(u128, H256)>
Claim value from the mailbox message identified by message_id
.
Sends the
pallet_gear::claim_value
extrinsic.
This function returns a tuple with value and block hash containing the corresponding transaction.
§See also
claim_value_batch
function claims a batch of values from the mailbox.
sourcepub async fn claim_value_batch(
&self,
args: impl IntoIterator<Item = MessageId> + Clone,
) -> Result<(Vec<Result<u128>>, H256)>
pub async fn claim_value_batch( &self, args: impl IntoIterator<Item = MessageId> + Clone, ) -> Result<(Vec<Result<u128>>, H256)>
Claim a batch of values from the mailbox.
A batch is a set of requests to be executed within one function call.
Every entry of the args
iterator is a message identifier used in the
claim_value
function. It is useful when
processing multiple replies in the mailbox at once.
sourcepub async fn send_message_bytes(
&self,
destination: ProgramId,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, H256)>
pub async fn send_message_bytes( &self, destination: ProgramId, payload: impl AsRef<[u8]>, gas_limit: u64, value: u128, ) -> Result<(MessageId, H256)>
Send a message containing a byte slice payload
to the destination
.
The message also contains the maximum gas_limit
that can be spent and
the value
to be transferred to the destination
’s account.
Sends the
pallet_gear::send_message
extrinsic.
This function returns a tuple with a new message identifier and a hash of the block with the message enqueuing transaction.
§See also
send_message
function sends a message with an encoded payload.send_message_bytes_batch
function sends a batch of messages.
sourcepub async fn send_message_bytes_batch(
&self,
args: impl IntoIterator<Item = (ProgramId, impl AsRef<[u8]>, u64, u128)>,
) -> Result<(Vec<Result<(MessageId, ProgramId)>>, H256)>
pub async fn send_message_bytes_batch( &self, args: impl IntoIterator<Item = (ProgramId, impl AsRef<[u8]>, u64, u128)>, ) -> Result<(Vec<Result<(MessageId, ProgramId)>>, H256)>
Send a batch of messages.
A batch is a set of messages to be sent within one function call. Every
entry of the args
iterator is a tuple of parameters used in the
send_message_bytes
function. It is useful
when invoking several programs at once or sending a sequence of messages
to one program.
sourcepub async fn send_message(
&self,
destination: ProgramId,
payload: impl Encode,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, H256)>
pub async fn send_message( &self, destination: ProgramId, payload: impl Encode, gas_limit: u64, value: u128, ) -> Result<(MessageId, H256)>
Same as send_message_bytes
, but sends a
message with encoded payload
.
sourcepub async fn send_reply_bytes(
&self,
reply_to_id: MessageId,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, u128, H256)>
pub async fn send_reply_bytes( &self, reply_to_id: MessageId, payload: impl AsRef<[u8]>, gas_limit: u64, value: u128, ) -> Result<(MessageId, u128, H256)>
Send a reply containing a byte slice payload
to the message identified
by reply_to_id
.
The reply also contains the maximum gas_limit
that can be spent and
the value
to be transferred to the destination’s account.
Sends the
pallet_gear::send_reply
extrinsic.
This function returns a tuple with a new message identifier, transferred value, and a hash of the block with the message enqueuing transaction.
§See also
send_reply
function sends a reply with an encoded payload.send_reply_bytes_batch
function send a batch of replies.
sourcepub async fn send_reply_bytes_batch(
&self,
args: impl IntoIterator<Item = (MessageId, impl AsRef<[u8]>, u64, u128)> + Clone,
) -> Result<(Vec<Result<(MessageId, ProgramId, u128)>>, H256)>
pub async fn send_reply_bytes_batch( &self, args: impl IntoIterator<Item = (MessageId, impl AsRef<[u8]>, u64, u128)> + Clone, ) -> Result<(Vec<Result<(MessageId, ProgramId, u128)>>, H256)>
Send a batch of replies.
A batch is a set of replies to be sent within one function call. Every
entry of the args
iterator is a tuple of parameters used in the
send_reply_bytes
function. It is useful when
replying to several programs at once.
The output for each call slightly differs from
send_reply_bytes
as the destination
program id is also returned in the resulting tuple.
sourcepub async fn send_reply(
&self,
reply_to_id: MessageId,
payload: impl Encode,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, u128, H256)>
pub async fn send_reply( &self, reply_to_id: MessageId, payload: impl Encode, gas_limit: u64, value: u128, ) -> Result<(MessageId, u128, H256)>
Same as send_reply_bytes
, but sends a reply
with encoded payload
.
sourcepub async fn upload_code(
&self,
code: impl AsRef<[u8]>,
) -> Result<(CodeId, H256)>
pub async fn upload_code( &self, code: impl AsRef<[u8]>, ) -> Result<(CodeId, H256)>
Upload Wasm code
to be used for creating a new program.
Sends the
pallet_gear::upload_code
extrinsic.
This function returns a tuple with a code identifier and a hash of the
block with the code uploading transaction. The code identifier can be
used when creating a program using the
create_program
function.
§See also
create_program
function creates a program from a previously uploaded code and initializes it.upload_program
function uploads a new program and initialize it.
sourcepub async fn upload_code_batch(
&self,
args: impl IntoIterator<Item = impl AsRef<[u8]>>,
) -> Result<(Vec<Result<CodeId>>, H256)>
pub async fn upload_code_batch( &self, args: impl IntoIterator<Item = impl AsRef<[u8]>>, ) -> Result<(Vec<Result<CodeId>>, H256)>
Upload a batch of codes.
A batch is a set of codes to be uploaded within one function call. Every
entry of the args
iterator is a byte slice used in the
upload_code
function. It is useful when deploying
a multi-program dApp.
sourcepub async fn upload_code_by_path(
&self,
path: impl AsRef<Path>,
) -> Result<(CodeId, H256)>
pub async fn upload_code_by_path( &self, path: impl AsRef<Path>, ) -> Result<(CodeId, H256)>
Upload Wasm code from the file referenced by path
to be used for
creating a new program.
Same as upload_code
, but reads the code from a
file instead of using a byte vector.
Works with absolute and relative paths (relative to the root dir of the repo).
sourcepub async fn upload_program_bytes(
&self,
code: impl AsRef<[u8]>,
salt: impl AsRef<[u8]>,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, ProgramId, H256)>
pub async fn upload_program_bytes( &self, code: impl AsRef<[u8]>, salt: impl AsRef<[u8]>, payload: impl AsRef<[u8]>, gas_limit: u64, value: u128, ) -> Result<(MessageId, ProgramId, H256)>
Upload a new program and initialize it with a byte slice payload
.
Sends the
pallet_gear::upload_program
extrinsic.
Parameters:
code
is the byte slice containing a binary Wasm code of the program;salt
is the arbitrary data needed to generate an address for a new program (control of salt uniqueness is entirely on the function caller’s side);payload
vector contains data to be processed in theinit
function of the newly deployed “child” program;gas_limit
is the maximum gas amount allowed to spend for the program creation and initialization;value
to be transferred to the program’s account during initialization.
§See also
create_program_bytes
function creates a program from a previously uploaded code.upload_code
function uploads a code and returns its identifier.upload_program
function uploads a program and initializes it with an encoded payload.
sourcepub async fn upload_program_bytes_batch(
&self,
args: impl IntoIterator<Item = (impl AsRef<[u8]>, impl AsRef<[u8]>, impl AsRef<[u8]>, u64, u128)>,
) -> Result<(Vec<Result<(MessageId, ProgramId)>>, H256)>
pub async fn upload_program_bytes_batch( &self, args: impl IntoIterator<Item = (impl AsRef<[u8]>, impl AsRef<[u8]>, impl AsRef<[u8]>, u64, u128)>, ) -> Result<(Vec<Result<(MessageId, ProgramId)>>, H256)>
Upload a batch of programs.
A batch is a set of programs to be uploaded within one function call.
Every entry of the args
iterator is a tuple used in the
upload_program_bytes
function. It is
useful when deploying a multi-program dApp.
sourcepub async fn upload_program_bytes_by_path(
&self,
path: impl AsRef<Path>,
salt: impl AsRef<[u8]>,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, ProgramId, H256)>
pub async fn upload_program_bytes_by_path( &self, path: impl AsRef<Path>, salt: impl AsRef<[u8]>, payload: impl AsRef<[u8]>, gas_limit: u64, value: u128, ) -> Result<(MessageId, ProgramId, H256)>
Upload a new program from the file referenced by path
and initialize
it with a byte slice payload
.
Same as upload_program_bytes
, but reads
the program from a file instead of using a byte vector.
Works with absolute and relative paths (relative to the root dir of the repo).
sourcepub async fn upload_program(
&self,
code: impl AsRef<[u8]>,
salt: impl AsRef<[u8]>,
payload: impl Encode,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, ProgramId, H256)>
pub async fn upload_program( &self, code: impl AsRef<[u8]>, salt: impl AsRef<[u8]>, payload: impl Encode, gas_limit: u64, value: u128, ) -> Result<(MessageId, ProgramId, H256)>
Same as upload_program_bytes
, but
initializes a newly uploaded program with an encoded payload
.
§See also
create_program
function creates a program from a previously uploaded code.upload_code
function uploads a code and returns its identifier.
sourcepub async fn upload_program_by_path(
&self,
path: impl AsRef<Path>,
salt: impl AsRef<[u8]>,
payload: impl Encode,
gas_limit: u64,
value: u128,
) -> Result<(MessageId, ProgramId, H256)>
pub async fn upload_program_by_path( &self, path: impl AsRef<Path>, salt: impl AsRef<[u8]>, payload: impl Encode, gas_limit: u64, value: u128, ) -> Result<(MessageId, ProgramId, H256)>
Upload a new program from the file referenced by path
and initialize
it with an encoded payload
.
Same as upload_program
, but reads the program
from a file instead of using a byte vector.
Works with absolute and relative paths (relative to the root dir of the repo).
sourcepub async fn set_code(&self, code: impl AsRef<[u8]>) -> Result<H256>
pub async fn set_code(&self, code: impl AsRef<[u8]>) -> Result<H256>
Upgrade the runtime with the code
containing the Wasm code of the new
runtime.
Sends the
pallet_system::set_code
extrinsic.
sourcepub async fn set_code_by_path(&self, path: impl AsRef<Path>) -> Result<H256>
pub async fn set_code_by_path(&self, path: impl AsRef<Path>) -> Result<H256>
Upgrade the runtime by reading the code from the file located at the
path
.
Same as set_code
, but reads the runtime code from a
file instead of using a byte vector.
sourcepub async fn set_code_without_checks(
&self,
code: impl AsRef<[u8]>,
) -> Result<H256>
pub async fn set_code_without_checks( &self, code: impl AsRef<[u8]>, ) -> Result<H256>
Upgrade the runtime with the code
containing the Wasm code of the new
runtime but without checks.
Sends the
pallet_system::set_code_without_checks
extrinsic.
sourcepub async fn set_code_without_checks_by_path(
&self,
path: impl AsRef<Path>,
) -> Result<H256>
pub async fn set_code_without_checks_by_path( &self, path: impl AsRef<Path>, ) -> Result<H256>
Upgrade the runtime by reading the code from the file located at the
path
.
Same as set_code_without_checks
, but
reads the runtime code from a file instead of using a byte vector.
sourcepub async fn force_set_balance(
&self,
to: impl Into<MultiAddress<AccountId32, ()>>,
new_free: u128,
) -> Result<H256>
pub async fn force_set_balance( &self, to: impl Into<MultiAddress<AccountId32, ()>>, new_free: u128, ) -> Result<H256>
Set the free balance of the to
account to new_free
.
Sends the pallet_balances::set_balance
extrinsic.
sourcepub async fn upload_code_with_voucher(
&self,
voucher_id: VoucherId,
code: impl AsRef<[u8]>,
) -> Result<(CodeId, H256)>
pub async fn upload_code_with_voucher( &self, voucher_id: VoucherId, code: impl AsRef<[u8]>, ) -> Result<(CodeId, H256)>
Same as upload_code
, but upload code
using voucher.
sourcepub async fn send_message_bytes_with_voucher(
&self,
voucher_id: VoucherId,
destination: ProgramId,
payload: impl AsRef<[u8]>,
gas_limit: u64,
value: u128,
keep_alive: bool,
) -> Result<(MessageId, H256)>
pub async fn send_message_bytes_with_voucher( &self, voucher_id: VoucherId, destination: ProgramId, payload: impl AsRef<[u8]>, gas_limit: u64, value: u128, keep_alive: bool, ) -> Result<(MessageId, H256)>
Same as send_message_bytes
, but sends a
message using voucher.
sourcepub async fn send_message_with_voucher(
&self,
voucher_id: VoucherId,
destination: ProgramId,
payload: impl Encode,
gas_limit: u64,
value: u128,
keep_alive: bool,
) -> Result<(MessageId, H256)>
pub async fn send_message_with_voucher( &self, voucher_id: VoucherId, destination: ProgramId, payload: impl Encode, gas_limit: u64, value: u128, keep_alive: bool, ) -> Result<(MessageId, H256)>
Same as send_message_bytes_with_voucher
, but sends a
message with encoded payload
.
source§impl GearApi
impl GearApi
sourcepub async fn calculate_create_gas(
&self,
origin: Option<H256>,
code_id: CodeId,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
) -> Result<GasInfo>
pub async fn calculate_create_gas( &self, origin: Option<H256>, code_id: CodeId, payload: Vec<u8>, value: u128, allow_other_panics: bool, ) -> Result<GasInfo>
Execute an RPC to calculate the gas required to create a program from a code and process an initialization message.
Actually sends the gear_calculateInitCreateGas
RPC to the node. The
function’s parameters are:
origin
(optional) is the caller’s public address;code_id
is the uploaded code identifier that can be obtained by calling theupload_code
function;payload
vector contains data to be processed by the program;value
to be transferred to the program’s account;allow_other_panics
flag indicates ignoring a trap during the program’s execution;at
(optional) allows executing the RPC at the specified block identified by its hash.
sourcepub async fn calculate_create_gas_at(
&self,
origin: Option<H256>,
code_id: CodeId,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
at: Option<H256>,
) -> Result<GasInfo>
pub async fn calculate_create_gas_at( &self, origin: Option<H256>, code_id: CodeId, payload: Vec<u8>, value: u128, allow_other_panics: bool, at: Option<H256>, ) -> Result<GasInfo>
Same as calculate_create_gas
, but
calculates the gas at the block identified by its hash.
sourcepub async fn calculate_upload_gas(
&self,
origin: Option<H256>,
code: Vec<u8>,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
) -> Result<GasInfo>
pub async fn calculate_upload_gas( &self, origin: Option<H256>, code: Vec<u8>, payload: Vec<u8>, value: u128, allow_other_panics: bool, ) -> Result<GasInfo>
Execute an RPC to calculate the gas required to upload a program and process an initialization message.
Actually sends the gear_calculateInitUploadGas
RPC to the node. The
function’s parameters are:
origin
(optional) is the caller’s public address;code
is the buffer containing the Wasm binary code of the Gear program;payload
vector contains data to be processed by the program;value
to be transferred to the program’s account;allow_other_panics
flag indicates ignoring a trap during the program’s execution;at
(optional) allows executing the RPC at the specified block identified by its hash.
sourcepub async fn calculate_upload_gas_at(
&self,
origin: Option<H256>,
code: Vec<u8>,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
at: Option<H256>,
) -> Result<GasInfo>
pub async fn calculate_upload_gas_at( &self, origin: Option<H256>, code: Vec<u8>, payload: Vec<u8>, value: u128, allow_other_panics: bool, at: Option<H256>, ) -> Result<GasInfo>
Same as calculate_upload_gas
, but
calculates the gas at the block identified by its hash.
sourcepub async fn calculate_handle_gas(
&self,
origin: Option<H256>,
destination: ProgramId,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
) -> Result<GasInfo>
pub async fn calculate_handle_gas( &self, origin: Option<H256>, destination: ProgramId, payload: Vec<u8>, value: u128, allow_other_panics: bool, ) -> Result<GasInfo>
Execute an RPC to calculate the gas required to handle a message.
Actually sends the gear_calculateHandleGas
RPC to the node. The
function’s parameters are:
origin
(optional) is the caller’s public address;destination
is the program address;payload
vector contains data to be processed by the program;value
to be transferred to the program’s account;allow_other_panics
flag indicates ignoring a trap during the program’s execution;at
(optional) allows executing the RPC at the specified block identified by its hash.
sourcepub async fn calculate_handle_gas_at(
&self,
origin: Option<H256>,
destination: ProgramId,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
at: Option<H256>,
) -> Result<GasInfo>
pub async fn calculate_handle_gas_at( &self, origin: Option<H256>, destination: ProgramId, payload: Vec<u8>, value: u128, allow_other_panics: bool, at: Option<H256>, ) -> Result<GasInfo>
Same as calculate_handle_gas
, but
calculates the gas at the block identified by its hash.
sourcepub async fn calculate_reply_gas(
&self,
origin: Option<H256>,
message_id: MessageId,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
) -> Result<GasInfo>
pub async fn calculate_reply_gas( &self, origin: Option<H256>, message_id: MessageId, payload: Vec<u8>, value: u128, allow_other_panics: bool, ) -> Result<GasInfo>
Execute an RPC to calculate the gas required to reply to the received message from the mailbox.
Actually sends the gear_calculateReplyGas
RPC to the node. The
function’s parameters are:
origin
(optional) is the caller’s public address;message_id
is a message identifier required to find it in the mailbox;exit_code
is the status code of the reply;payload
vector contains data to be processed by the program;value
to be transferred to the program’s account;allow_other_panics
flag indicates ignoring a trap during the program’s execution;at
(optional) allows executing the RPC at the specified block identified by its hash.
sourcepub async fn calculate_reply_gas_at(
&self,
origin: Option<H256>,
message_id: MessageId,
payload: Vec<u8>,
value: u128,
allow_other_panics: bool,
at: Option<H256>,
) -> Result<GasInfo>
pub async fn calculate_reply_gas_at( &self, origin: Option<H256>, message_id: MessageId, payload: Vec<u8>, value: u128, allow_other_panics: bool, at: Option<H256>, ) -> Result<GasInfo>
Same as calculate_reply_gas
, but
calculates the gas at the block identified by its hash.
sourcepub async fn read_state_bytes(
&self,
program_id: ProgramId,
payload: Vec<u8>,
) -> Result<Vec<u8>>
pub async fn read_state_bytes( &self, program_id: ProgramId, payload: Vec<u8>, ) -> Result<Vec<u8>>
Read the program’s state as a byte vector.
sourcepub async fn read_state_bytes_at(
&self,
program_id: ProgramId,
payload: Vec<u8>,
at: Option<H256>,
) -> Result<Vec<u8>>
pub async fn read_state_bytes_at( &self, program_id: ProgramId, payload: Vec<u8>, at: Option<H256>, ) -> Result<Vec<u8>>
Same as read_state_bytes
, but reads the
program’s state at the block identified by its hash.
sourcepub async fn read_state<D: Decode>(
&self,
program_id: ProgramId,
payload: Vec<u8>,
) -> Result<D>
pub async fn read_state<D: Decode>( &self, program_id: ProgramId, payload: Vec<u8>, ) -> Result<D>
Read the program’s state as decoded data.
sourcepub async fn read_state_at<D: Decode>(
&self,
program_id: ProgramId,
payload: Vec<u8>,
at: Option<H256>,
) -> Result<D>
pub async fn read_state_at<D: Decode>( &self, program_id: ProgramId, payload: Vec<u8>, at: Option<H256>, ) -> Result<D>
Same as read_state
, but reads the program’s state
at the block identified by its hash.
sourcepub async fn read_state_bytes_using_wasm(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
wasm: Vec<u8>,
argument: Option<Vec<u8>>,
) -> Result<Vec<u8>>
pub async fn read_state_bytes_using_wasm( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, wasm: Vec<u8>, argument: Option<Vec<u8>>, ) -> Result<Vec<u8>>
Read the program’s state as a byte vector using a meta Wasm.
sourcepub async fn read_state_bytes_using_wasm_at(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
wasm: Vec<u8>,
argument: Option<Vec<u8>>,
at: Option<H256>,
) -> Result<Vec<u8>>
pub async fn read_state_bytes_using_wasm_at( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, wasm: Vec<u8>, argument: Option<Vec<u8>>, at: Option<H256>, ) -> Result<Vec<u8>>
Same as read_state_bytes_using_wasm
, but reads the program’s state at the block identified by its hash.
sourcepub async fn read_state_using_wasm<E: Encode, D: Decode>(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
wasm: Vec<u8>,
argument: Option<E>,
) -> Result<D>
pub async fn read_state_using_wasm<E: Encode, D: Decode>( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, wasm: Vec<u8>, argument: Option<E>, ) -> Result<D>
Read the program’s state as decoded data using a meta Wasm.
sourcepub async fn read_state_using_wasm_at<E: Encode, D: Decode>(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
wasm: Vec<u8>,
argument: Option<E>,
at: Option<H256>,
) -> Result<D>
pub async fn read_state_using_wasm_at<E: Encode, D: Decode>( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, wasm: Vec<u8>, argument: Option<E>, at: Option<H256>, ) -> Result<D>
Same as read_state_using_wasm
, but
reads the program’s state at the block identified by its hash.
sourcepub async fn read_state_bytes_using_wasm_by_path(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
path: impl AsRef<Path>,
argument: Option<Vec<u8>>,
) -> Result<Vec<u8>>
pub async fn read_state_bytes_using_wasm_by_path( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, path: impl AsRef<Path>, argument: Option<Vec<u8>>, ) -> Result<Vec<u8>>
Read the program’s state using a meta Wasm file referenced by its
path
.
sourcepub async fn read_state_bytes_using_wasm_by_path_at(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
path: impl AsRef<Path>,
argument: Option<Vec<u8>>,
at: Option<H256>,
) -> Result<Vec<u8>>
pub async fn read_state_bytes_using_wasm_by_path_at( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, path: impl AsRef<Path>, argument: Option<Vec<u8>>, at: Option<H256>, ) -> Result<Vec<u8>>
Same as read_state_using_wasm_by_path
, but reads the program’s state at the block identified by its hash.
sourcepub async fn read_state_using_wasm_by_path<E: Encode, D: Decode>(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
path: impl AsRef<Path>,
argument: Option<E>,
) -> Result<D>
pub async fn read_state_using_wasm_by_path<E: Encode, D: Decode>( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, path: impl AsRef<Path>, argument: Option<E>, ) -> Result<D>
Read the program’s state using a meta Wasm file referenced by its
path
.
sourcepub async fn read_state_using_wasm_by_path_at<E: Encode, D: Decode>(
&self,
program_id: ProgramId,
payload: Vec<u8>,
fn_name: &str,
path: impl AsRef<Path>,
argument: Option<E>,
at: Option<H256>,
) -> Result<D>
pub async fn read_state_using_wasm_by_path_at<E: Encode, D: Decode>( &self, program_id: ProgramId, payload: Vec<u8>, fn_name: &str, path: impl AsRef<Path>, argument: Option<E>, at: Option<H256>, ) -> Result<D>
Same as read_state_using_wasm_by_path
, but reads the program’s state at the block identified by its hash.
sourcepub async fn read_metahash(&self, program_id: ProgramId) -> Result<H256>
pub async fn read_metahash(&self, program_id: ProgramId) -> Result<H256>
Read the program’s metahash.
sourcepub async fn read_metahash_at(
&self,
program_id: ProgramId,
at: Option<H256>,
) -> Result<H256>
pub async fn read_metahash_at( &self, program_id: ProgramId, at: Option<H256>, ) -> Result<H256>
Same as read_metahash
, but read the program’s
metahash at the block identified by its hash.
sourcepub async fn calculate_reply_for_handle(
&self,
origin: Option<H256>,
destination: ProgramId,
payload: Vec<u8>,
gas_limit: u64,
value: u128,
) -> Result<ReplyInfo>
pub async fn calculate_reply_for_handle( &self, origin: Option<H256>, destination: ProgramId, payload: Vec<u8>, gas_limit: u64, value: u128, ) -> Result<ReplyInfo>
Execute an RPC call is used to figure out the reply on calling
Gear::send_message(..)
.
Actually sends the gear_calculateReplyForHandle
RPC to the node. The
function’s parameters are:
origin
(optional) is the caller’s public address;destination
is the program address;payload
vector contains data to be processed by the program;gas_limit
: maximum amount of gas the program can spend before it is halted.value
to be transferred to the program’s account;at
(optional) allows executing the RPC at the specified block identified by its hash.
source§impl GearApi
impl GearApi
sourcepub fn block_gas_limit(&self) -> Result<u64>
pub fn block_gas_limit(&self) -> Result<u64>
Return the total gas limit per block (also known as a gas budget).
sourcepub fn expected_block_time(&self) -> Result<u64>
pub fn expected_block_time(&self) -> Result<u64>
The expected average block time at which BABE should be creating blocks.
Since BABE is probabilistic it is not trivial to figure out what the
expected average block time should be based on the slot duration and the
security parameter c
(where 1 - c
represents the probability of a
slot being empty).
sourcepub async fn last_block_hash(&self) -> Result<H256>
pub async fn last_block_hash(&self) -> Result<H256>
Return a hash of the last block.
sourcepub async fn last_block_number(&self) -> Result<u32>
pub async fn last_block_number(&self) -> Result<u32>
Return a number of the last block (also known as block height).
sourcepub async fn last_events(&self) -> Result<Vec<RuntimeEvent>>
pub async fn last_events(&self) -> Result<Vec<RuntimeEvent>>
Return vector of events contained in the last block.
sourcepub async fn block_number_at(&self, block_hash: H256) -> Result<u32>
pub async fn block_number_at(&self, block_hash: H256) -> Result<u32>
Return a number of the specified block identified by the block_hash
.
sourcepub async fn get_block_hash(&self, block_number: u32) -> Result<H256>
pub async fn get_block_hash(&self, block_number: u32) -> Result<H256>
Get a hash of a block identified by its block_number
.
sourcepub async fn last_block_timestamp(&self) -> Result<u64>
pub async fn last_block_timestamp(&self) -> Result<u64>
Return a timestamp of the last block.
The timestamp is the number of milliseconds elapsed since the Unix epoch.
sourcepub async fn events_at(&self, block_hash: H256) -> Result<Vec<RuntimeEvent>>
pub async fn events_at(&self, block_hash: H256) -> Result<Vec<RuntimeEvent>>
Return vector of events contained in the specified block identified by
the block_hash
.
sourcepub async fn events_since(
&self,
block_hash: H256,
max_depth: usize,
) -> Result<Vec<RuntimeEvent>>
pub async fn events_since( &self, block_hash: H256, max_depth: usize, ) -> Result<Vec<RuntimeEvent>>
Return vector of events contained in blocks since the block identified
by the block_hash
but no more than in max_depth
blocks.
sourcepub async fn queue_processing_enabled(&self) -> Result<bool>
pub async fn queue_processing_enabled(&self) -> Result<bool>
Check whether the message queue processing is stopped or not.
sourcepub async fn queue_processing_stalled(&self) -> Result<bool>
pub async fn queue_processing_stalled(&self) -> Result<bool>
Looks at two blocks from the stream and checks if the Gear block number has grown from block to block or not.
source§impl GearApi
impl GearApi
sourcepub async fn get_mailbox_message(
&self,
message_id: MessageId,
) -> Result<Option<(UserStoredMessage, Interval<u32>)>>
pub async fn get_mailbox_message( &self, message_id: MessageId, ) -> Result<Option<(UserStoredMessage, Interval<u32>)>>
Get a message identified by message_id
from the mailbox.
sourcepub async fn get_mailbox_account_message(
&self,
account_id: impl IntoAccountId32,
message_id: MessageId,
) -> Result<Option<(UserStoredMessage, Interval<u32>)>>
pub async fn get_mailbox_account_message( &self, account_id: impl IntoAccountId32, message_id: MessageId, ) -> Result<Option<(UserStoredMessage, Interval<u32>)>>
Get a message identified by message_id
from the account_id
’s
mailbox.
sourcepub async fn get_mailbox_account_messages(
&self,
account_id: impl IntoAccountId32,
count: u32,
) -> Result<Vec<(UserStoredMessage, Interval<u32>)>>
pub async fn get_mailbox_account_messages( &self, account_id: impl IntoAccountId32, count: u32, ) -> Result<Vec<(UserStoredMessage, Interval<u32>)>>
Get up to count
messages from the mailbox for
the provided account_id
.
sourcepub async fn get_mailbox_messages(
&self,
count: u32,
) -> Result<Vec<(UserStoredMessage, Interval<u32>)>>
pub async fn get_mailbox_messages( &self, count: u32, ) -> Result<Vec<(UserStoredMessage, Interval<u32>)>>
Get up to count
messages from the mailbox.
sourcepub async fn total_balance(
&self,
account_id: impl IntoAccountId32,
) -> Result<u128>
pub async fn total_balance( &self, account_id: impl IntoAccountId32, ) -> Result<u128>
Get the total balance of the account identified by account_id
.
Total balance includes free and reserved funds.
sourcepub async fn free_balance(
&self,
account_id: impl IntoAccountId32,
) -> Result<u128>
pub async fn free_balance( &self, account_id: impl IntoAccountId32, ) -> Result<u128>
Get the free funds balance of the account identified by account_id
.
sourcepub async fn reserved_balance(
&self,
account_id: impl IntoAccountId32,
) -> Result<u128>
pub async fn reserved_balance( &self, account_id: impl IntoAccountId32, ) -> Result<u128>
Get the reserved funds balance of the account identified by
account_id
.
source§impl GearApi
impl GearApi
sourcepub async fn issue_voucher(
&self,
spender: ProgramId,
balance: u128,
programs: Option<Vec<ProgramId>>,
code_uploading: bool,
duration: u32,
) -> Result<(VoucherId, H256)>
pub async fn issue_voucher( &self, spender: ProgramId, balance: u128, programs: Option<Vec<ProgramId>>, code_uploading: bool, duration: u32, ) -> Result<(VoucherId, H256)>
Issue a new voucher.
Returns issued voucher_id
at specified at_block_hash
.
Arguments:
- spender: user id that is eligible to use the voucher;
- balance: voucher balance could be used for transactions fees and gas;
- programs: pool of programs spender can interact with, if None - means any program, limited by Config param;
- code_uploading: allow voucher to be used as payer for
upload_code
transactions fee; - duration: amount of blocks voucher could be used by spender and couldn’t be revoked by owner. Must be out in [MinDuration; MaxDuration] constants. Expiration block of the voucher calculates as: current bn (extrinsic exec bn) + duration + 1.
sourcepub async fn update_voucher(
&self,
spender: ProgramId,
voucher_id: VoucherId,
move_ownership: Option<ProgramId>,
balance_top_up: Option<u128>,
append_programs: Option<Option<Vec<ProgramId>>>,
code_uploading: Option<bool>,
prolong_duration: u32,
) -> Result<(VoucherId, H256)>
pub async fn update_voucher( &self, spender: ProgramId, voucher_id: VoucherId, move_ownership: Option<ProgramId>, balance_top_up: Option<u128>, append_programs: Option<Option<Vec<ProgramId>>>, code_uploading: Option<bool>, prolong_duration: u32, ) -> Result<(VoucherId, H256)>
Update existing voucher.
This extrinsic updates existing voucher: it can only extend vouchers rights in terms of balance, validity or programs to interact pool.
Can only be called by the voucher owner.
Arguments:
- spender: account id of the voucher spender;
- voucher_id: voucher id to be updated;
- move_ownership: optionally moves ownership to another account;
- balance_top_up: optionally top ups balance of the voucher from origins balance;
- append_programs: optionally extends pool of programs by
Some(programs_set)
passed or allows it to interact with any program byNone
passed; - code_uploading: optionally allows voucher to be used to pay fees for
upload_code
extrinsics; - prolong_duration: optionally increases expiry block number. If voucher is expired, prolongs since current bn. Validity prolongation (since current block number for expired or since storage written expiry) should be in [MinDuration; MaxDuration], in other words voucher couldn’t have expiry greater than current block number + MaxDuration.
sourcepub async fn revoke_voucher(
&self,
spender: ProgramId,
voucher_id: VoucherId,
) -> Result<(VoucherId, H256)>
pub async fn revoke_voucher( &self, spender: ProgramId, voucher_id: VoucherId, ) -> Result<(VoucherId, H256)>
Revoke existing voucher.
This extrinsic revokes existing voucher, if current block is greater than expiration block of the voucher (it is no longer valid).
Currently it means sending of all balance from voucher account to voucher owner without voucher removal from storage map, but this behavior may change in future, as well as the origin validation: only owner is able to revoke voucher now.
Arguments:
- spender: account id of the voucher spender;
- voucher_id: voucher id to be revoked.
source§impl GearApi
impl GearApi
sourcepub async fn init(address: WSAddress) -> Result<Self>
pub async fn init(address: WSAddress) -> Result<Self>
Create and init a new GearApi
specified by its address
on behalf of
the default Alice
user.
sourcepub async fn init_with(
address: WSAddress,
suri: impl AsRef<str>,
) -> Result<Self>
pub async fn init_with( address: WSAddress, suri: impl AsRef<str>, ) -> Result<Self>
Create and init a new GearApi
specified by its address
and suri
.
SURI is a Substrate URI that identifies a user by a mnemonic phrase or
provides default users from the keyring (e.g., “//Alice”, “//Bob”,
etc.). The password for URI should be specified in the same suri
,
separated by the ':'
char.
sourcepub fn with(self, suri: impl AsRef<str>) -> Result<Self>
pub fn with(self, suri: impl AsRef<str>) -> Result<Self>
Change SURI to the provided suri
and return Self
.
sourcepub async fn dev() -> Result<Self>
pub async fn dev() -> Result<Self>
Create and init a new GearApi
instance that will be used with the
local node working in developer mode (running with --dev
argument).
sourcepub async fn dev_from_path(path: impl AsRef<OsStr>) -> Result<Self>
pub async fn dev_from_path(path: impl AsRef<OsStr>) -> Result<Self>
Create and init a new GearApi
instance via spawning a new node process
in development mode using the --dev
flag and listening on an a
random port number. The node process uses a binary specified by the
path
param. Ideally, the binary should be downloaded by means of CI pipeline from https://get.gear.rs.
sourcepub async fn vara_dev_from_path(path: impl AsRef<OsStr>) -> Result<Self>
pub async fn vara_dev_from_path(path: impl AsRef<OsStr>) -> Result<Self>
Create and init a new GearApi
instance via spawning a new node process
in development mode using the --chain=vara-dev
, --validator
,
--tmp
flags and listening on an a random port number. The node
process uses a binary specified by the path
param. Ideally, the
binary should be downloaded by means of CI pipeline from https://get.gear.rs.
sourcepub fn print_node_logs(&mut self)
pub fn print_node_logs(&mut self)
Print node logs.
sourcepub async fn vara_testnet() -> Result<Self>
pub async fn vara_testnet() -> Result<Self>
Create and init a new GearApi
instance that will be used with the
public Vara testnet node.
sourcepub async fn vara() -> Result<Self>
pub async fn vara() -> Result<Self>
Create and init a new GearApi
instance that will be used with the
public Vara node.
sourcepub async fn subscribe(&self) -> Result<EventListener>
pub async fn subscribe(&self) -> Result<EventListener>
Create an EventListener
to subscribe and handle continuously
incoming events.
sourcepub fn set_nonce(&mut self, nonce: u64)
pub fn set_nonce(&mut self, nonce: u64)
Set the number used once (nonce
) that will be used while sending
extrinsics.
If set, this nonce is added to the extrinsic and provides a unique identifier of the transaction sent by the current account. The nonce shows how many prior transactions have occurred from this account. This helps protect against replay attacks or accidental double-submissions.
sourcepub async fn rpc_nonce(&self) -> Result<u64>
pub async fn rpc_nonce(&self) -> Result<u64>
Get the next number used once (nonce
) from the node.
Actually sends the system_accountNextIndex
RPC to the node.
sourcepub fn account_id(&self) -> &AccountId32
pub fn account_id(&self) -> &AccountId32
Return the signer account address.
§Examples
use gclient::{GearApi, Result};
use gsdk::ext::sp_runtime::AccountId32;
#[tokio::test]
async fn account_test() -> Result<()> {
let api = GearApi::dev().await?;
let alice_id = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d");
assert_eq!(api.account_id(), &AccountId32::from(alice_id));
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GearApi
impl !RefUnwindSafe for GearApi
impl Send for GearApi
impl Sync for GearApi
impl Unpin for GearApi
impl !UnwindSafe for GearApi
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FromBits<T> for T
impl<T> FromBits<T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.