pub struct PythClient { /* private fields */ }
Expand description
Client type for Pyth Hermes.
See the documentation for each endpoint in Swagger.
Implementations§
Source§impl PythClient
Streams
impl PythClient
Streams
Sourcepub async fn stream_price_updates(
&self,
ids: Vec<PriceIdInput>,
encoding: Option<EncodingType>,
parsed: Option<bool>,
allow_unordered: Option<bool>,
benchmarks_only: Option<bool>,
) -> Result<impl Stream<Item = Result<PriceUpdate, Error>> + use<>, Error>
Available on crate feature stream
only.
pub async fn stream_price_updates( &self, ids: Vec<PriceIdInput>, encoding: Option<EncodingType>, parsed: Option<bool>, allow_unordered: Option<bool>, benchmarks_only: Option<bool>, ) -> Result<impl Stream<Item = Result<PriceUpdate, Error>> + use<>, Error>
stream
only.SSE route handler for streaming price updates.
Arguments:
ids
: Get the most recent price update for this set of price feed ids.encoding
: Optional encoding type. If set, return the price update in the encoding specified by the encoding parameter. Default isEncodingType::Hex
.parsed
: Iftrue
, include the parsed price update inPriceUpdate::parsed
. Defaults tofalse
for this client.allow_unordered
: Iftrue
, allows unordered price updates to be included in the stream.benchmarks_only
: Iftrue
, only include benchmark prices that are the initial price updates at a given timestamp (i.e., prevPubTime != pubTime).
/v2/updates/price/stream
Source§impl PythClient
impl PythClient
pub fn new(url: Url) -> Self
pub fn new_with_client(client: Client, url: Url) -> Self
Sourcepub async fn price_feeds(
&self,
query: String,
asset_type: Option<AssetType>,
) -> Result<Vec<PriceFeedMetadata>, Error>
pub async fn price_feeds( &self, query: String, asset_type: Option<AssetType>, ) -> Result<Vec<PriceFeedMetadata>, Error>
Get the set of price feeds.
This endpoint fetches all price feeds from the Pyth network. It can be filtered by asset type and query string.
Arguments:
query
: If provided, the results will be filtered to all price feeds whose symbol contains the query string. Query string is case insensitive. Example: “bitcoin”asset_type
: If provided, the results will be filtered by asset type.
/v2/price_feeds
Sourcepub async fn latest_price_update(
&self,
ids: Vec<PriceIdInput>,
encoding: Option<EncodingType>,
parsed: Option<bool>,
) -> Result<PriceUpdate, Error>
pub async fn latest_price_update( &self, ids: Vec<PriceIdInput>, encoding: Option<EncodingType>, parsed: Option<bool>, ) -> Result<PriceUpdate, Error>
Get the latest price updates by price feed id.
Given a collection of price feed ids, retrieve the latest Pyth price for each price feed.
Arguments:
ids
: Get the most recent price update for this set of price feed ids.encoding
: Optional encoding type. If set, return the price update in the encoding specified by the encoding parameter. Default isEncodingType::Hex
.parsed
: Iftrue
, include the parsed price update inPriceUpdate::parsed
. Defaults tofalse
for this client.
/v2/updates/price/latest
Sourcepub async fn price_update(
&self,
publish_time: u64,
ids: Vec<PriceIdInput>,
encoding: Option<EncodingType>,
parsed: Option<bool>,
) -> Result<PriceUpdate, Error>
pub async fn price_update( &self, publish_time: u64, ids: Vec<PriceIdInput>, encoding: Option<EncodingType>, parsed: Option<bool>, ) -> Result<PriceUpdate, Error>
Get the latest price updates by price feed id.
Given a collection of price feed ids, retrieve the latest Pyth price for each price feed.
Arguments:
publish_time
: The unix timestamp in seconds. This endpoint will return the first update whosepublish_time
is >= the provided value.ids
: Get the price update for this set of price feed ids.encoding
: Optional encoding type. If set, return the price update in the encoding specified by the encoding parameter. Default isEncodingType::Hex
.parsed
: Iftrue
, include the parsed price update inPriceUpdate::parsed
. Defaults tofalse
for this client.
/v2/updates/price/{publish_time}
Trait Implementations§
Source§impl Clone for PythClient
impl Clone for PythClient
Source§fn clone(&self) -> PythClient
fn clone(&self) -> PythClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for PythClient
impl !RefUnwindSafe for PythClient
impl Send for PythClient
impl Sync for PythClient
impl Unpin for PythClient
impl !UnwindSafe for PythClient
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