xmtp_api_d14n/protocol/traits/
full_api.rs

1use std::sync::Arc;
2
3use xmtp_proto::{
4    api::IsConnectedCheck,
5    api_client::{BoxedGroupS, BoxedWelcomeS},
6    prelude::{XmtpIdentityClient, XmtpMlsClient, XmtpMlsStreams},
7};
8
9use crate::protocol::XmtpQuery;
10
11/// A type-erased version of the Xmtp Api in a [`Box`]
12pub type FullXmtpApiBox<Err> = Box<dyn FullXmtpApiT<Err>>;
13/// A type-erased version of the Xntp Api in a [`Arc`]
14pub type FullXmtpApiArc<Err> = Arc<dyn FullXmtpApiT<Err>>;
15
16// TODO: Can remove boxes once switchover to d14n (one client) is complete.
17
18/// Trait combining all other api traits into one
19/// Used for describing the entire XmtpApi from
20/// the client perspective in a single `dyn Trait`
21/// or otherwise requiring the full capabilities
22/// of the API.
23/// Requiring the full capabilities outside of a dyn should generally be avoided
24/// unless the consumer wants to be unnecessarily general/restrictive.
25pub trait FullXmtpApiT<Err>
26where
27    Self: XmtpMlsClient<Error = Err>
28        + XmtpIdentityClient<Error = Err>
29        + XmtpMlsStreams<
30            Error = Err,
31            WelcomeMessageStream = BoxedWelcomeS<Err>,
32            GroupMessageStream = BoxedGroupS<Err>,
33        > + IsConnectedCheck
34        + XmtpQuery<Error = Err>
35        + 'static,
36{
37}
38
39impl<T, Err> FullXmtpApiT<Err> for T where
40    T: XmtpMlsClient<Error = Err>
41        + XmtpIdentityClient<Error = Err>
42        + XmtpMlsStreams<
43            Error = Err,
44            WelcomeMessageStream = BoxedWelcomeS<Err>,
45            GroupMessageStream = BoxedGroupS<Err>,
46        > + IsConnectedCheck
47        + XmtpQuery<Error = Err>
48        + ?Sized
49        + 'static
50{
51}