Struct cosmwasm_std::SubMsg
source · [−]pub struct SubMsg<T = Empty> {
pub id: u64,
pub msg: CosmosMsg<T>,
pub gas_limit: Option<u64>,
pub reply_on: ReplyOn,
}
Expand description
A submessage that will guarantee a reply
call on success or error, depending on
the reply_on
setting. If you do not need to process the result, use regular messages instead.
Note: On error the submessage execution will revert any partial state changes due to this message,
but not revert any state changes in the calling contract. If this is required, it must be done
manually in the reply
entry point.
Fields
id: u64
An arbitrary ID chosen by the contract.
This is typically used to match Reply
s in the reply
entry point to the submessage.
msg: CosmosMsg<T>
gas_limit: Option<u64>
reply_on: ReplyOn
Implementations
sourceimpl<T> SubMsg<T>
impl<T> SubMsg<T>
sourcepub fn new(msg: impl Into<CosmosMsg<T>>) -> Self
pub fn new(msg: impl Into<CosmosMsg<T>>) -> Self
new creates a “fire and forget” message with the pre-0.14 semantics
sourcepub fn reply_on_success(msg: impl Into<CosmosMsg<T>>, id: u64) -> Self
pub fn reply_on_success(msg: impl Into<CosmosMsg<T>>, id: u64) -> Self
create a SubMsg
that will provide a reply
with the given id if the message returns Ok
sourcepub fn reply_on_error(msg: impl Into<CosmosMsg<T>>, id: u64) -> Self
pub fn reply_on_error(msg: impl Into<CosmosMsg<T>>, id: u64) -> Self
create a SubMsg
that will provide a reply
with the given id if the message returns Err
sourcepub fn reply_always(msg: impl Into<CosmosMsg<T>>, id: u64) -> Self
pub fn reply_always(msg: impl Into<CosmosMsg<T>>, id: u64) -> Self
create a SubMsg
that will always provide a reply
with the given id
sourcepub fn with_gas_limit(self, limit: u64) -> Self
pub fn with_gas_limit(self, limit: u64) -> Self
Add a gas limit to the message.
Examples
let sub_msg: SubMsg = SubMsg::reply_always(msg, 1234).with_gas_limit(60_000);
assert_eq!(sub_msg.id, 1234);
assert_eq!(sub_msg.gas_limit, Some(60_000));
assert_eq!(sub_msg.reply_on, ReplyOn::Always);
Trait Implementations
sourceimpl<'de, T> Deserialize<'de> for SubMsg<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for SubMsg<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: JsonSchema> JsonSchema for SubMsg<T>
impl<T: JsonSchema> JsonSchema for SubMsg<T>
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the $ref
keyword. Read more
impl<T> StructuralPartialEq for SubMsg<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for SubMsg<T> where
T: RefUnwindSafe,
impl<T> Send for SubMsg<T> where
T: Send,
impl<T> Sync for SubMsg<T> where
T: Sync,
impl<T> Unpin for SubMsg<T> where
T: Unpin,
impl<T> UnwindSafe for SubMsg<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more