pub struct CoinbaseInstrumentProvider { /* private fields */ }Expand description
Loads and caches Coinbase instruments.
Wraps a CoinbaseHttpClient and provides methods for loading instruments
from the REST API or from pre-fetched JSON responses. Parsed instruments are
cached in the HTTP client’s shared AtomicMap.
Implementations§
Source§impl CoinbaseInstrumentProvider
impl CoinbaseInstrumentProvider
Sourcepub fn new(client: CoinbaseHttpClient) -> Self
pub fn new(client: CoinbaseHttpClient) -> Self
Creates a new CoinbaseInstrumentProvider.
Sourcepub fn instruments(&self) -> &Arc<AtomicMap<InstrumentId, InstrumentAny>> ⓘ
pub fn instruments(&self) -> &Arc<AtomicMap<InstrumentId, InstrumentAny>> ⓘ
Returns a reference to the instrument cache.
Sourcepub fn get(&self, instrument_id: &InstrumentId) -> Option<InstrumentAny>
pub fn get(&self, instrument_id: &InstrumentId) -> Option<InstrumentAny>
Returns a cached instrument by ID, if present.
Sourcepub async fn load_all(&self) -> Result<Vec<InstrumentAny>>
pub async fn load_all(&self) -> Result<Vec<InstrumentAny>>
Loads all instruments from the Coinbase REST API and caches them.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub async fn load_all_filtered(
&self,
product_type: CoinbaseProductType,
) -> Result<Vec<InstrumentAny>>
pub async fn load_all_filtered( &self, product_type: CoinbaseProductType, ) -> Result<Vec<InstrumentAny>>
Loads all instruments of a specific product type from the REST API.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub async fn load(&self, product_id: &str) -> Result<InstrumentAny>
pub async fn load(&self, product_id: &str) -> Result<InstrumentAny>
Loads a single instrument by product ID from the REST API.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub fn load_from_products_response(
&self,
json: &Value,
) -> Result<Vec<InstrumentAny>>
pub fn load_from_products_response( &self, json: &Value, ) -> Result<Vec<InstrumentAny>>
Parses a products list response and caches the instruments.
Expects the JSON shape returned by GET /products: {"products": [...]}.
§Errors
Returns an error if the JSON cannot be deserialized or any product fails to parse.
Sourcepub fn load_from_products_response_filtered(
&self,
json: &Value,
product_type: CoinbaseProductType,
) -> Result<Vec<InstrumentAny>>
pub fn load_from_products_response_filtered( &self, json: &Value, product_type: CoinbaseProductType, ) -> Result<Vec<InstrumentAny>>
Parses a products list response, filtering by product type, and caches the instruments.
§Errors
Returns an error if the JSON cannot be deserialized or any product fails to parse.
Sourcepub fn load_from_product_response(&self, json: &Value) -> Result<InstrumentAny>
pub fn load_from_product_response(&self, json: &Value) -> Result<InstrumentAny>
Parses a single product response and caches the instrument.
Expects the JSON shape returned by GET /products/{product_id}.
§Errors
Returns an error if the JSON cannot be deserialized or the product fails to parse.
Trait Implementations§
Source§impl Clone for CoinbaseInstrumentProvider
impl Clone for CoinbaseInstrumentProvider
Source§fn clone(&self) -> CoinbaseInstrumentProvider
fn clone(&self) -> CoinbaseInstrumentProvider
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CoinbaseInstrumentProvider
impl !RefUnwindSafe for CoinbaseInstrumentProvider
impl Send for CoinbaseInstrumentProvider
impl Sync for CoinbaseInstrumentProvider
impl Unpin for CoinbaseInstrumentProvider
impl UnsafeUnpin for CoinbaseInstrumentProvider
impl !UnwindSafe for CoinbaseInstrumentProvider
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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