pub struct NotificationHandler { /* private fields */ }
Expand description

Object that allows receiving notifications of the different events of relevance that a node performs and/or detects.

These objects can only be obtained through a node that has already been initialized. In case of multiple nodes, the same handler cannot be used to obtain notifications from each of them. Instead, one must be instantiated for each node in the application and they will only be able to receive notifications from that point on, the previous ones being unrecoverable.

Implementations

It forces the object to wait until the arrival of a new notification. It is important to note that handlers have an internal queue for storing messages. This queue starts acting from the moment the object is created, allowing the object to retrieve notifications from that moment until the current one. In this case, the method returns instantly with the oldest notification.

An Error will only be obtained if it is not possible to receive more notifications due to a node stop and if there are no messages queued. In such a situation, the handler becomes useless and its release from memory is recommended.

The handler tries to get a notification. If there is none, it returns instead of waiting. Because of this, this method can be used to determine if the notification queue is empty, since it will report such a possibility with an error.

Possible results

• A notification will be obtained only if it exists in the object’s queue.
Error::CantReceiveNotification will be obtained if it is not possible to receive more notifications.
Error::NoNewNotification will be obtained if there is no message queued and it is still possible to continue receiving messages.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more