cli_sky/lexicon/
wrapper.rs

1use crate::lexicon::client::{AtpServiceClient, Service};
2use std::sync::Arc;
3use atrium_xrpc::XrpcClient;
4
5// Implement new for Service
6impl<T> Service<T>
7where
8    T: XrpcClient + Send + Sync + 'static,
9{
10    pub fn new(xrpc: Arc<T>) -> Self {
11        Self {
12            _phantom: std::marker::PhantomData,
13        }
14    }
15}
16
17pub struct ServiceWrapper<T>
18where
19    T: XrpcClient + Send + Sync + 'static,
20{
21    inner: Service<T>,
22}
23
24impl<T> ServiceWrapper<T>
25where
26    T: XrpcClient + Send + Sync + 'static,
27{
28    pub fn new(xrpc: Arc<T>) -> Self {
29        Self {
30            inner: Service::new(xrpc),
31        }
32    }
33}
34
35pub struct AtpServiceClientWrapper<T>
36where
37    T: XrpcClient + Send + Sync + 'static,
38{
39    inner: AtpServiceClient<T>,
40}
41
42impl<T> AtpServiceClientWrapper<T>
43where
44    T: XrpcClient + Send + Sync + 'static,
45{
46    pub fn new(xrpc: T) -> Self {
47        let service = ServiceWrapper::new(Arc::new(xrpc)).inner;
48        Self {
49            inner: AtpServiceClient { service },
50        }
51    }
52}