pub struct Events(/* private fields */);
Expand description
Events publishes events for the currently executing contract.
use soroban_sdk::Env;
let event = env.events();
let data = map![&env, (1u32, 2u32)];
// topics can be represented with tuple up to a certain length
let topics0 = ();
let topics1 = (0u32,);
let topics2 = (0u32, 1u32);
let topics3 = (0u32, 1u32, 2u32);
let topics4 = (0u32, 1u32, 2u32, 3u32);
// topics can also be represented with a `Vec` with no length limit
let topics5 = vec![&env, 4u32, 5u32, 6u32, 7u32, 8u32];
event.publish(topics0, data.clone());
event.publish(topics1, data.clone());
event.publish(topics2, data.clone());
event.publish(topics3, data.clone());
event.publish(topics4, data.clone());
event.publish(topics5, data.clone());
Implementations§
Source§impl Events
impl Events
Sourcepub fn publish_event(&self, e: &(impl Event + ?Sized))
pub fn publish_event(&self, e: &(impl Event + ?Sized))
Publish an event defined using the contractevent
macro.
Sourcepub fn publish<T, D>(&self, topics: T, data: D)
👎Deprecated: use the #[contractevent] macro on a contract event type
pub fn publish<T, D>(&self, topics: T, data: D)
Publish an event.
Consider using contractevent
instead of this function.
Event data is specified in data
. Data may be any value or
type, including types defined by contracts using contracttype.
Event topics must not contain:
- Vec
- Map
- Bytes/BytesN longer than 32 bytes
- contracttype
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Events
impl !RefUnwindSafe for Events
impl !Send for Events
impl !Sync for Events
impl Unpin for Events
impl !UnwindSafe for Events
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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>
Converts
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>
Converts
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