pub struct RestClient { /* private fields */ }Available on crate feature
rest-client only.Expand description
A simple REST client for requesting resources using HTTP GET.
Implementations§
Source§impl RestClient
impl RestClient
Sourcepub fn new(base_url: String) -> Self
pub fn new(base_url: String) -> Self
Creates a new REST client connected to the given endpoint.
The base URL should include the REST path component (e.g., “http://127.0.0.1:8332/rest”).
Sourcepub async fn request_resource<F, T>(
&self,
resource_path: &str,
) -> Result<T, HttpClientError>
pub async fn request_resource<F, T>( &self, resource_path: &str, ) -> Result<T, HttpClientError>
Requests a resource encoded in F format and interpreted as type T.
Trait Implementations§
Source§impl BlockSource for RestClient
impl BlockSource for RestClient
Source§fn get_header<'a>(
&'a self,
header_hash: &'a BlockHash,
_height: Option<u32>,
) -> impl Future<Output = BlockSourceResult<BlockHeaderData>> + Send + 'a
fn get_header<'a>( &'a self, header_hash: &'a BlockHash, _height: Option<u32>, ) -> impl Future<Output = BlockSourceResult<BlockHeaderData>> + Send + 'a
Returns the header for a given hash. A height hint may be provided in case a block source
cannot easily find headers based on a hash. This is merely a hint and thus the returned
header must have the same hash as was requested. Otherwise, an error must be returned. Read more
Source§fn get_block<'a>(
&'a self,
header_hash: &'a BlockHash,
) -> impl Future<Output = BlockSourceResult<BlockData>> + Send + 'a
fn get_block<'a>( &'a self, header_hash: &'a BlockHash, ) -> impl Future<Output = BlockSourceResult<BlockData>> + Send + 'a
Returns the block for a given hash. A headers-only block source should return a
Transient
error.Source§fn get_best_block<'a>(
&'a self,
) -> impl Future<Output = BlockSourceResult<(BlockHash, Option<u32>)>> + Send + 'a
fn get_best_block<'a>( &'a self, ) -> impl Future<Output = BlockSourceResult<(BlockHash, Option<u32>)>> + Send + 'a
Returns the hash of the best block and, optionally, its height. Read more
Source§impl UtxoSource for RestClient
impl UtxoSource for RestClient
Source§fn get_block_hash_by_height<'a>(
&'a self,
block_height: u32,
) -> impl Future<Output = BlockSourceResult<BlockHash>> + Send + 'a
fn get_block_hash_by_height<'a>( &'a self, block_height: u32, ) -> impl Future<Output = BlockSourceResult<BlockHash>> + Send + 'a
Fetches the block hash of the block at the given height. Read more
Source§fn is_output_unspent<'a>(
&'a self,
outpoint: OutPoint,
) -> impl Future<Output = BlockSourceResult<bool>> + Send + 'a
fn is_output_unspent<'a>( &'a self, outpoint: OutPoint, ) -> impl Future<Output = BlockSourceResult<bool>> + Send + 'a
Returns true if the given output has not been spent, i.e. is a member of the current UTXO
set.
Auto Trait Implementations§
impl Freeze for RestClient
impl RefUnwindSafe for RestClient
impl Send for RestClient
impl Sync for RestClient
impl Unpin for RestClient
impl UnsafeUnpin for RestClient
impl UnwindSafe for RestClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more