#[non_exhaustive]pub struct IbcBasicResponse<T = Empty> {
pub messages: Vec<SubMsg<T>>,
pub attributes: Vec<Attribute>,
pub events: Vec<Event>,
}
Expand description
This is the return value for the majority of the ibc handlers. That are able to dispatch messages / events on their own, but have no meaningful return value to the calling code.
Callbacks that have return values (like receive_packet) or that cannot redispatch messages (like the handshake callbacks) will use other Response types
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.messages: Vec<SubMsg<T>>
Optional list of messages to pass. These will be executed in order.
If the ReplyOn member is set, they will invoke this contract’s reply
entry point
after execution. Otherwise, they act like “fire and forget”.
Use SubMsg::new
to create messages with the older “fire and forget” semantics.
attributes: Vec<Attribute>
The attributes that will be emitted as part of a wasm
event.
More info about events (and their attributes) can be found in Cosmos SDK docs.
events: Vec<Event>
Extra, custom events separate from the main wasm
one. These will have
wasm-
prepended to the type.
More info about events can be found in Cosmos SDK docs.
Implementations§
Source§impl<T> IbcBasicResponse<T>
impl<T> IbcBasicResponse<T>
pub fn new() -> Self
Sourcepub fn add_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn add_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add an attribute included in the main wasm
event.
Sourcepub fn add_message(self, msg: impl Into<CosmosMsg<T>>) -> Self
pub fn add_message(self, msg: impl Into<CosmosMsg<T>>) -> Self
This creates a “fire and forget” message, by using SubMsg::new()
to wrap it,
and adds it to the list of messages to process.
Sourcepub fn add_submessage(self, msg: SubMsg<T>) -> Self
pub fn add_submessage(self, msg: SubMsg<T>) -> Self
This takes an explicit SubMsg (creates via e.g. reply_on_error
)
and adds it to the list of messages to process.
Sourcepub fn add_event(self, event: Event) -> Self
pub fn add_event(self, event: Event) -> Self
Adds an extra event to the response, separate from the main wasm
event
that is always created.
The wasm-
prefix will be appended by the runtime to the provided type
of event.
Sourcepub fn add_attributes<A: Into<Attribute>>(
self,
attrs: impl IntoIterator<Item = A>,
) -> Self
pub fn add_attributes<A: Into<Attribute>>( self, attrs: impl IntoIterator<Item = A>, ) -> Self
Bulk add attributes included in the main wasm
event.
Anything that can be turned into an iterator and yields something
that can be converted into an Attribute
is accepted.
§Examples
use cosmwasm_std::{attr, IbcBasicResponse};
let attrs = vec![
("action", "reaction"),
("answer", "42"),
("another", "attribute"),
];
let res: IbcBasicResponse = IbcBasicResponse::new().add_attributes(attrs.clone());
assert_eq!(res.attributes, attrs);
Sourcepub fn add_messages<M: Into<CosmosMsg<T>>>(
self,
msgs: impl IntoIterator<Item = M>,
) -> Self
pub fn add_messages<M: Into<CosmosMsg<T>>>( self, msgs: impl IntoIterator<Item = M>, ) -> Self
Bulk add “fire and forget” messages to the list of messages to process.
§Examples
use cosmwasm_std::{CosmosMsg, IbcBasicResponse};
fn make_response_with_msgs(msgs: Vec<CosmosMsg>) -> IbcBasicResponse {
IbcBasicResponse::new().add_messages(msgs)
}
Sourcepub fn add_submessages(self, msgs: impl IntoIterator<Item = SubMsg<T>>) -> Self
pub fn add_submessages(self, msgs: impl IntoIterator<Item = SubMsg<T>>) -> Self
Bulk add explicit SubMsg structs to the list of messages to process.
§Examples
use cosmwasm_std::{SubMsg, IbcBasicResponse};
fn make_response_with_submsgs(msgs: Vec<SubMsg>) -> IbcBasicResponse {
IbcBasicResponse::new().add_submessages(msgs)
}
Sourcepub fn add_events(self, events: impl IntoIterator<Item = Event>) -> Self
pub fn add_events(self, events: impl IntoIterator<Item = Event>) -> Self
Bulk add custom events to the response. These are separate from the main
wasm
event.
The wasm-
prefix will be appended by the runtime to the provided types
of events.
Trait Implementations§
Source§impl<T: Clone> Clone for IbcBasicResponse<T>
impl<T: Clone> Clone for IbcBasicResponse<T>
Source§fn clone(&self) -> IbcBasicResponse<T>
fn clone(&self) -> IbcBasicResponse<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Debug> Debug for IbcBasicResponse<T>
impl<T: Debug> Debug for IbcBasicResponse<T>
Source§impl<T> Default for IbcBasicResponse<T>
impl<T> Default for IbcBasicResponse<T>
Source§impl<'de, T> Deserialize<'de> for IbcBasicResponse<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for IbcBasicResponse<T>where
T: Deserialize<'de>,
Source§fn 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>,
Source§impl<T: JsonSchema> JsonSchema for IbcBasicResponse<T>
impl<T: JsonSchema> JsonSchema for IbcBasicResponse<T>
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl<T: PartialEq> PartialEq for IbcBasicResponse<T>
impl<T: PartialEq> PartialEq for IbcBasicResponse<T>
Source§impl<T> Serialize for IbcBasicResponse<T>where
T: Serialize,
impl<T> Serialize for IbcBasicResponse<T>where
T: Serialize,
impl<T: Eq> Eq for IbcBasicResponse<T>
impl<T> StructuralPartialEq for IbcBasicResponse<T>
Auto Trait Implementations§
impl<T> Freeze for IbcBasicResponse<T>
impl<T> RefUnwindSafe for IbcBasicResponse<T>where
T: RefUnwindSafe,
impl<T> Send for IbcBasicResponse<T>where
T: Send,
impl<T> Sync for IbcBasicResponse<T>where
T: Sync,
impl<T> Unpin for IbcBasicResponse<T>where
T: Unpin,
impl<T> UnwindSafe for IbcBasicResponse<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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