use redup_bootstrap_grpc::CallContext;
use tonic::Request;
use tonic::transport::Channel;
use super::clients;
use crate::error::ClientError;
use crate::factory::{Calls, Settings};
use redup_bootstrap_grpc::contracts::redup::bootstrap::v1::InstanceInfo;
use redup_bootstrap_grpc::contracts::redup::bootstrap::v1::info_client::InfoClient as Generated;
const EXPLAIN: &str = "/redup.bootstrap.v1.Info/Explain";
pub struct InfoClient {
calls: Calls,
plain: Generated<Channel>,
_compressed: Option<Generated<Channel>>,
_settings: std::sync::Arc<Settings>,
}
impl InfoClient {
pub(crate) fn new(calls: Calls, channel: Channel) -> Self {
let (plain, compressed, settings) = clients!(Generated<Channel>, calls, channel);
Self {
calls,
plain,
_compressed: compressed,
_settings: settings,
}
}
pub async fn explain(&mut self, context: &CallContext) -> Result<InstanceInfo, ClientError> {
let calls = self.calls.clone();
let (request, timeout, trace) = calls.prepare(Request::new(()), context, false);
let response = calls
.unary(
EXPLAIN,
context,
timeout,
trace,
self.plain.explain(request),
)
.await?;
Ok(response.into_inner())
}
}