nullnet_libdatastore/
experimental.rs1use crate::{
2 DatastoreConfig,
3 store::{
4 CreateConnectionsRequest, CreateConnectionsResponse, DeleteConnectionsRequest,
5 DeleteConnectionsResponse, GetConnectionsRequest, GetConnectionsResponse,
6 UpdateConnectionsRequest, UpdateConnectionsResponse,
7 store_service_client::StoreServiceClient,
8 },
9};
10use nullnet_liberror::{Error, ErrorHandler, Location, location};
11use tonic::transport::Channel;
12
13pub struct ExperimentalDatastoreClient {
14 client: StoreServiceClient<Channel>,
15}
16
17impl ExperimentalDatastoreClient {
18 #[allow(clippy::missing_errors_doc)]
19 pub async fn new(config: DatastoreConfig) -> Result<Self, Error> {
20 let channel = config.connect().await?;
21 let client = StoreServiceClient::new(channel).max_decoding_message_size(50 * 1024 * 1024);
22 Ok(Self { client })
23 }
24
25 pub async fn create_connections(
26 &mut self,
27 request: CreateConnectionsRequest,
28 ) -> Result<CreateConnectionsResponse, Error> {
29 let response = self
30 .client
31 .create_connections(request)
32 .await
33 .handle_err(location!())?;
34
35 Ok(response.into_inner())
36 }
37
38 pub async fn get_connections(
39 &mut self,
40 request: GetConnectionsRequest,
41 ) -> Result<GetConnectionsResponse, Error> {
42 let response = self
43 .client
44 .get_connections(request)
45 .await
46 .handle_err(location!())?;
47
48 Ok(response.into_inner())
49 }
50
51 pub async fn update_connections(
52 &mut self,
53 request: UpdateConnectionsRequest,
54 ) -> Result<UpdateConnectionsResponse, Error> {
55 let response = self
56 .client
57 .update_connections(request)
58 .await
59 .handle_err(location!())?;
60
61 Ok(response.into_inner())
62 }
63
64 pub async fn delete_connections(
65 &mut self,
66 request: DeleteConnectionsRequest,
67 ) -> Result<DeleteConnectionsResponse, Error> {
68 let response = self
69 .client
70 .delete_connections(request)
71 .await
72 .handle_err(location!())?;
73
74 Ok(response.into_inner())
75 }
76}