Skip to main content

RestClientChainService

Struct RestClientChainService 

Source
pub struct RestClientChainService { /* private fields */ }
Expand description

REST-backed BitcoinChainService.

The trait is exported through UniFFI with with_foreign, which makes UniFFI re-wrap every Arc<dyn BitcoinChainService> that round-trips across the FFI boundary in a foreign-callback proxy — even when both sides are Rust in the same process. That proxy routes calls back into Rust via UniFFI’s RustFuture, which is polled outside the surrounding tokio runtime context, so reqwest’s tokio::time::sleep panics with “no reactor running”.

To stay correct under round-tripping (e.g. shared-chain-service in a server-side harness that builds the service in Rust, hands it to a foreign-language integration, and passes it back into multiple SDK instances), we capture a [tokio::runtime::Handle] at construction time and dispatch each trait-method body onto it via [tokio::runtime::Handle::spawn]. The outer future we return to UniFFI is just a JoinHandle await — a channel-wakeup poll that needs no tokio context.

Implementations§

Source§

impl RestClientChainService

Source

pub fn new( base_url: String, network: Network, max_retries: usize, http_client: Arc<dyn HttpClient>, basic_auth: Option<BasicAuth>, api_type: ChainApiType, ) -> Self

Trait Implementations§

Source§

impl BitcoinChainService for RestClientChainService

Source§

fn get_address_utxos<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Vec<Utxo>, ChainServiceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_transaction_status<'life0, 'async_trait>( &'life0 self, txid: String, ) -> Pin<Box<dyn Future<Output = Result<TxStatus, ChainServiceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_transaction_hex<'life0, 'async_trait>( &'life0 self, txid: String, ) -> Pin<Box<dyn Future<Output = Result<String, ChainServiceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn broadcast_transaction<'life0, 'async_trait>( &'life0 self, tx: String, ) -> Pin<Box<dyn Future<Output = Result<(), ChainServiceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn recommended_fees<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RecommendedFees, ChainServiceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more