nebula_client/v1/storage/
client.rs1use bytes::Bytes;
2use fbthrift::{BinaryProtocol, Transport};
3use nebula_fbthrift_storage_v1::{
4 client::{StorageService, StorageServiceImpl},
5 errors::storage_service::{ScanEdgeError, ScanVertexError},
6 types::{ScanEdgeRequest, ScanEdgeResponse, ScanVertexRequest, ScanVertexResponse},
7};
8
9struct StorageConnection<T>
13where
14 T: Transport,
15 Bytes: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
16 ::fbthrift::ProtocolEncoded<BinaryProtocol>:
17 ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
18{
19 service: StorageServiceImpl<BinaryProtocol, T>,
20}
21
22impl<T> StorageConnection<T>
23where
24 T: Transport,
25 Bytes: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
26 ::fbthrift::ProtocolEncoded<BinaryProtocol>:
27 ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
28{
29 fn new(transport: T) -> Self {
30 Self {
31 service: StorageServiceImpl::<BinaryProtocol, _>::new(transport),
32 }
33 }
34}
35
36pub struct StorageClient<T>
40where
41 T: Transport,
42 Bytes: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
43 ::fbthrift::ProtocolEncoded<BinaryProtocol>:
44 ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
45{
46 connection: StorageConnection<T>,
47}
48
49impl<T> StorageClient<T>
50where
51 T: Transport,
52 Bytes: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
53 ::fbthrift::ProtocolEncoded<BinaryProtocol>:
54 ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
55{
56 pub fn new(transport: T) -> Self {
57 Self {
58 connection: StorageConnection::new(transport),
59 }
60 }
61
62 pub async fn scan_vertex(
63 &self,
64 req: &ScanVertexRequest,
65 ) -> Result<ScanVertexResponse, ScanVertexError> {
66 let res = self.connection.service.scanVertex(req).await?;
67
68 Ok(res)
69 }
70
71 pub async fn scan_edge(
72 &self,
73 req: &ScanEdgeRequest,
74 ) -> Result<ScanEdgeResponse, ScanEdgeError> {
75 let res = self.connection.service.scanEdge(req).await?;
76
77 Ok(res)
78 }
79}