1
use async_trait::async_trait;
2
use bonsaidb_core::{
3
    custom_api::CustomApi,
4
    keyvalue::KeyValue,
5
    networking::{DatabaseRequest, DatabaseResponse, Request, Response},
6
};
7

            
8
#[async_trait]
9
impl<A> KeyValue for super::RemoteDatabase<A>
10
where
11
    A: CustomApi,
12
{
13
20224
    async fn execute_key_operation(
14
20224
        &self,
15
20224
        op: bonsaidb_core::keyvalue::KeyOperation,
16
20224
    ) -> Result<bonsaidb_core::keyvalue::Output, bonsaidb_core::Error> {
17
20224
        match self
18
20224
            .client
19
20224
            .send_request(Request::Database {
20
20224
                database: self.name.to_string(),
21
20224
                request: DatabaseRequest::ExecuteKeyOperation(op),
22
20228
            })
23
20228
            .await?
24
        {
25
20214
            Response::Database(DatabaseResponse::KvOutput(output)) => Ok(output),
26
8
            Response::Error(err) => Err(err),
27
            other => Err(bonsaidb_core::Error::Networking(
28
                bonsaidb_core::networking::Error::UnexpectedResponse(format!("{:?}", other)),
29
            )),
30
        }
31
40448
    }
32
}