xmtp_api_d14n/protocol/traits/ordered_collection.rs
1use xmtp_common::{MaybeSend, MaybeSync};
2
3use crate::protocol::ResolutionError;
4
5// these functions are not on `EnvelopeCollection` to keep its object-safety simpler.
6// since dependency resolution requires `async fn`.
7/// A ordered envelope collection
8/// an `OrderedEnvelopeCollection` differs from [`Sort`](super::Sort)
9/// since it adds the including of `async`, allowing
10/// an `OrderedEnvelopeCollection` to both
11/// [Sort](super::Sort) and [ResolveDependencies](super::ResolveDependencies)
12#[xmtp_common::async_trait]
13pub trait OrderedEnvelopeCollection: MaybeSend + MaybeSync {
14 /// Order dependencies of `Self` according to [XIP](https://github.com/xmtp/XIPs/blob/main/XIPs/xip-49-decentralized-backend.md#335-cross-originator-message-ordering)
15 async fn order(&mut self) -> Result<(), ResolutionError>;
16
17 /// order without trying to resolve dependencies
18 fn order_offline(&mut self) -> Result<(), ResolutionError>;
19}