Struct coinbase_rs::public::Public

source ·
pub struct Public { /* private fields */ }

Implementations§

source§

impl Public

source

pub fn new(uri: &str) -> Self

Examples found in repository?
examples/current_time.rs (line 5)
4
5
6
7
async fn main() {
    let client = Public::new(MAIN_URL);
    println!("Server time is {:?}", client.current_time().await.unwrap());
}
More examples
Hide additional examples
examples/get_currencies.rs (line 7)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
async fn main() {
    let client = Public::new(MAIN_URL);

    let currencies = client.currencies();
    pin_mut!(currencies);

    while let Some(currencies_result) = currencies.next().await {
        for currency in currencies_result.unwrap() {
            println!(
                "Currency {} mininum size = {}",
                currency.name, currency.min_size
            );
        }
    }
}
source

pub fn currencies<'a>( &'a self ) -> impl Stream<Item = Result<Vec<Currency>>> + 'a

Get currencies

List known currencies. Currency codes will conform to the ISO 4217 standard where possible. Currencies which have or had no representation in ISO 4217 may use a custom code (e.g. BTC).

https://developers.coinbase.com/api/v2#currencies

Examples found in repository?
examples/get_currencies.rs (line 9)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
async fn main() {
    let client = Public::new(MAIN_URL);

    let currencies = client.currencies();
    pin_mut!(currencies);

    while let Some(currencies_result) = currencies.next().await {
        for currency in currencies_result.unwrap() {
            println!(
                "Currency {} mininum size = {}",
                currency.name, currency.min_size
            );
        }
    }
}
source

pub async fn exchange_rates(&self, currency: &str) -> Result<ExchangeRates>

Get exchange rates

Get current exchange rates. Default base currency is USD but it can be defined as any supported currency. Returned rates will define the exchange rate for one unit of the base currency.

https://developers.coinbase.com/api/v2#exchange-rates

source

pub async fn buy_price(&self, pair: &str) -> Result<CurrencyPrice>

Get buy price

Get the total price to buy one bitcoin or ether.

https://developers.coinbase.com/api/v2#get-buy-price

source

pub async fn sell_price(&self, currency_pair: &str) -> Result<CurrencyPrice>

Get sell price

Get the total price to sell one bitcoin or ether.

https://developers.coinbase.com/api/v2#get-sell-price

source

pub async fn spot_price( &self, currency_pair: &str, _date: Option<NaiveDate> ) -> Result<CurrencyPrice>

Get spot price

Get the current market price for a currency pair. This is usually somewhere in between the buy and sell price.

https://developers.coinbase.com/api/v2#get-spot-price

source

pub async fn current_time(&self) -> Result<Time>

Get current time

Get the API server time.

https://developers.coinbase.com/api/v2#time

Examples found in repository?
examples/current_time.rs (line 6)
4
5
6
7
async fn main() {
    let client = Public::new(MAIN_URL);
    println!("Server time is {:?}", client.current_time().await.unwrap());
}

Auto Trait Implementations§

§

impl !RefUnwindSafe for Public

§

impl Send for Public

§

impl Sync for Public

§

impl Unpin for Public

§

impl !UnwindSafe for Public

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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