Struct RestClient

Source
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

Source

pub fn new(endpoint: HttpEndpoint) -> Self

Creates a new REST client connected to the given endpoint.

The endpoint should contain the REST path component (e.g., http://127.0.0.1:8332/rest).

Source

pub async fn request_resource<F, T>(&self, resource_path: &str) -> Result<T>
where F: TryFrom<Vec<u8>, Error = Error> + TryInto<T, Error = Error>,

Requests a resource encoded in F format and interpreted as type T.

Trait Implementations§

Source§

impl BlockSource for RestClient

Source§

fn get_header<'a>( &'a self, header_hash: &'a BlockHash, _height: Option<u32>, ) -> AsyncBlockSourceResult<'a, BlockHeaderData>

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, ) -> AsyncBlockSourceResult<'a, BlockData>

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, ) -> AsyncBlockSourceResult<'a, (BlockHash, Option<u32>)>

Returns the hash of the best block and, optionally, its height. Read more
Source§

impl UtxoSource for RestClient

Source§

fn get_block_hash_by_height<'a>( &'a self, block_height: u32, ) -> AsyncBlockSourceResult<'a, BlockHash>

Fetches the block hash of the block at the given height. Read more
Source§

fn is_output_unspent<'a>( &'a self, outpoint: OutPoint, ) -> AsyncBlockSourceResult<'a, bool>

Returns true if the given output has not been spent, i.e. is a member of the current UTXO set.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.