Struct PythClient

Source
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

Source

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>

Available on crate feature 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 is EncodingType::Hex.
  • parsed: If true, include the parsed price update in PriceUpdate::parsed. Defaults to false for this client.
  • allow_unordered: If true, allows unordered price updates to be included in the stream.
  • benchmarks_only: If true, 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

Source

pub fn new(url: Url) -> Self

Source

pub fn new_with_client(client: Client, url: Url) -> Self

Source

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

Source

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 is EncodingType::Hex.
  • parsed: If true, include the parsed price update in PriceUpdate::parsed. Defaults to false for this client.

/v2/updates/price/latest

Source

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 whose publish_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 is EncodingType::Hex.
  • parsed: If true, include the parsed price update in PriceUpdate::parsed. Defaults to false for this client.

/v2/updates/price/{publish_time}

Trait Implementations§

Source§

impl Clone for PythClient

Source§

fn clone(&self) -> PythClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PythClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

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
Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,