Merge pull request #825 from jkczyz/2021-03-client-visibility

Expose RpcClient and RestClient interfaces as pub
This commit is contained in:
Matt Corallo 2021-03-05 09:44:28 -08:00 committed by GitHub
commit 1efc0c85eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -399,10 +399,10 @@ enum HttpMessageLength {
} }
/// An HTTP response body in binary format. /// An HTTP response body in binary format.
pub(crate) struct BinaryResponse(pub(crate) Vec<u8>); pub struct BinaryResponse(pub Vec<u8>);
/// An HTTP response body in JSON format. /// An HTTP response body in JSON format.
pub(crate) struct JsonResponse(pub(crate) serde_json::Value); pub struct JsonResponse(pub serde_json::Value);
/// Interprets bytes from an HTTP response body as binary data. /// Interprets bytes from an HTTP response body as binary data.
impl TryFrom<Vec<u8>> for BinaryResponse { impl TryFrom<Vec<u8>> for BinaryResponse {

View file

@ -24,7 +24,7 @@ impl RestClient {
} }
/// Requests a resource encoded in `F` format and interpreted as type `T`. /// Requests a resource encoded in `F` format and interpreted as type `T`.
async fn request_resource<F, T>(&mut self, resource_path: &str) -> std::io::Result<T> pub async fn request_resource<F, T>(&mut self, resource_path: &str) -> std::io::Result<T>
where F: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> { where F: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> {
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port()); let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path); let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path);

View file

@ -34,7 +34,7 @@ impl RpcClient {
} }
/// Calls a method with the response encoded in JSON format and interpreted as type `T`. /// Calls a method with the response encoded in JSON format and interpreted as type `T`.
async fn call_method<T>(&mut self, method: &str, params: &[serde_json::Value]) -> std::io::Result<T> pub async fn call_method<T>(&mut self, method: &str, params: &[serde_json::Value]) -> std::io::Result<T>
where JsonResponse: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> { where JsonResponse: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> {
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port()); let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
let uri = self.endpoint.path(); let uri = self.endpoint.path();