@@ -1207,11 +1207,17 @@ pub trait OnionMessageProvider {
12071207///
12081208/// # Requirements
12091209///
1210- /// See [`process_pending_events`] for requirements around event processing.
1211- ///
12121210/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
1213- /// event since the last invocation. The handler must either act upon the event immediately
1214- /// or preserve it for later handling.
1211+ /// event since the last invocation.
1212+ ///
1213+ /// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
1214+ /// and replay any unhandled events on startup. An [`Event`] is considered handled when
1215+ /// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
1216+ /// relevant changes to disk *before* returning.
1217+ ///
1218+ /// Further, because an application may crash between an [`Event`] being handled and the
1219+ /// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
1220+ /// effect, [`Event`]s may be replayed.
12151221///
12161222/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
12171223/// consult the provider's documentation on the implication of processing events and how a handler
@@ -1228,9 +1234,7 @@ pub trait OnionMessageProvider {
12281234pub trait EventsProvider {
12291235 /// Processes any events generated since the last call using the given event handler.
12301236 ///
1231- /// Subsequent calls must only process new events. However, handlers must be capable of handling
1232- /// duplicate events across process restarts. This may occur if the provider was recovered from
1233- /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
1237+ /// See the trait-level documentation for requirements.
12341238 fn process_pending_events < H : Deref > ( & self , handler : H ) where H :: Target : EventHandler ;
12351239}
12361240
0 commit comments