+//! Simple REST client implementation which implements [`BlockSource`] against a Bitcoin Core REST
+//! endpoint.
+
use crate::{BlockHeaderData, BlockSource, AsyncBlockSourceResult};
use crate::http::{BinaryResponse, HttpEndpoint, HttpClient, JsonResponse};
}
/// 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> {
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path);
let mut client = RestClient::new(server.endpoint()).unwrap();
match client.request_resource::<BinaryResponse, u32>("/").await {
- Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::NotFound),
+ Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::Other),
Ok(_) => panic!("Expected error"),
}
}