pub struct RpcClient { /* private fields */ }Expand description
Typed RPC client. One instance per fork, reused across fetches so reqwest can pool connections to the RPC.
Implementations§
Source§impl RpcClient
impl RpcClient
Sourcepub fn new(url: impl Into<String>, config: RpcConfig) -> Result<Self>
pub fn new(url: impl Into<String>, config: RpcConfig) -> Result<Self>
Build an RPC client for url with the given transport config.
Sourcepub fn get_latest_ledger(&self) -> Result<LatestLedger>
pub fn get_latest_ledger(&self) -> Result<LatestLedger>
Retrieve the latest ledger sequence, protocol version, and close time.
Issues two RPC calls: getLatestLedger (sequence + protocol) and
getLedgers for that sequence (close time). Both succeed or the
whole call fails — partial state would let the build proceed with
a wall-clock timestamp, which is exactly the silent fallback this
API is designed to avoid.
Sourcepub fn get_ledger_close_time(&self, sequence: u32) -> Result<u64>
pub fn get_ledger_close_time(&self, sequence: u32) -> Result<u64>
Fetch the close time (Unix seconds) of a specific ledger via
getLedgers. Returns an error if the ledger is outside the RPC’s
retention window.
Sourcepub fn get_network(&self) -> Result<NetworkMetadata>
pub fn get_network(&self) -> Result<NetworkMetadata>
Retrieve network metadata. The network_id is computed as
SHA-256 of the returned passphrase (per Stellar convention).
Sourcepub fn fetch_entries(&self, keys: &[LedgerKey]) -> Result<Vec<FetchedEntry>>
pub fn fetch_entries(&self, keys: &[LedgerKey]) -> Result<Vec<FetchedEntry>>
Fetch ledger entries in batches of max_keys_per_request. Missing
keys are simply absent from the returned vector — no error.
Sourcepub fn fetch_entry(&self, key: &LedgerKey) -> Result<Option<FetchedEntry>>
pub fn fetch_entry(&self, key: &LedgerKey) -> Result<Option<FetchedEntry>>
Convenience: fetch a single key. Returns None if absent.
Auto Trait Implementations§
impl Freeze for RpcClient
impl !RefUnwindSafe for RpcClient
impl Send for RpcClient
impl Sync for RpcClient
impl Unpin for RpcClient
impl UnsafeUnpin for RpcClient
impl !UnwindSafe for RpcClient
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
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more