Struct cosmwasm_std::IbcBasicResponse

source ·
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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>

source

pub fn new() -> Self

source

pub fn add_attribute( self, key: impl Into<String>, value: impl Into<String> ) -> Self

Add an attribute included in the main wasm event.

source

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.

source

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.

source

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.

source

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);
source

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)
}
source

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)
}
source

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>

source§

fn clone(&self) -> IbcBasicResponse<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for IbcBasicResponse<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for IbcBasicResponse<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: JsonSchema> JsonSchema for IbcBasicResponse<T>

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl<T: PartialEq> PartialEq for IbcBasicResponse<T>

source§

fn eq(&self, other: &IbcBasicResponse<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for IbcBasicResponse<T>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Eq> Eq for IbcBasicResponse<T>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<U> As for U

source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,