Struct InstrumentId
pub struct InstrumentId(/* private fields */);Expand description
Canonical stable instrument key.
Format: "spot:BTC-USD", "perp-linear:ETH-USDT",
"perp-inverse:BTC-USD", "future:BTC-USD:2025-06-27".
Implementations§
§impl InstrumentId
impl InstrumentId
pub fn from_kind(kind: &InstrumentKind) -> Result<Self, InvalidInstrumentId>
pub fn from_kind(kind: &InstrumentKind) -> Result<Self, InvalidInstrumentId>
Derive the canonical ID from an InstrumentKind.
pub fn spot(base: &str, quote: &str) -> Result<Self, InvalidInstrumentId>
pub fn spot(base: &str, quote: &str) -> Result<Self, InvalidInstrumentId>
Shorthand for InstrumentId of kind InstrumentKind::Spot.
pub fn perp_linear(base: &str, quote: &str) -> Result<Self, InvalidInstrumentId>
pub fn perp_linear(base: &str, quote: &str) -> Result<Self, InvalidInstrumentId>
Shorthand for InstrumentId of kind InstrumentKind::PerpetualLinear.
pub fn perp_inverse(
base: &str,
quote: &str,
) -> Result<Self, InvalidInstrumentId>
pub fn perp_inverse( base: &str, quote: &str, ) -> Result<Self, InvalidInstrumentId>
Shorthand for InstrumentId of kind InstrumentKind::PerpetualInverse.
pub fn as_str(&self) -> &str
pub fn kind(&self) -> InstrumentKind
pub fn base_asset(&self) -> Asset
pub fn quote_asset(&self) -> Asset
pub fn base_quote_assets(&self) -> (Asset, Asset)
pub fn base_quote_assets(&self) -> (Asset, Asset)
Lightweight extraction of (base, quote) assets from the canonical ID
string without constructing a full InstrumentKind.
All canonical formats place the pair as BASE-QUOTE after the first
:. Futures add a second :EXPIRY suffix that is stripped.
Trait Implementations§
§impl Clone for InstrumentId
impl Clone for InstrumentId
§fn clone(&self) -> InstrumentId
fn clone(&self) -> InstrumentId
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for InstrumentId
impl Debug for InstrumentId
§impl<'de> Deserialize<'de> for InstrumentId
impl<'de> Deserialize<'de> for InstrumentId
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Display for InstrumentId
impl Display for InstrumentId
§impl From<InstrumentId> for String
impl From<InstrumentId> for String
§fn from(id: InstrumentId) -> Self
fn from(id: InstrumentId) -> Self
Converts to this type from the input type.
§impl FromStr for InstrumentId
impl FromStr for InstrumentId
§impl Hash for InstrumentId
impl Hash for InstrumentId
§impl Ord for InstrumentId
impl Ord for InstrumentId
§impl PartialEq for InstrumentId
impl PartialEq for InstrumentId
§impl PartialOrd for InstrumentId
impl PartialOrd for InstrumentId
§impl Serialize for InstrumentId
impl Serialize for InstrumentId
§impl TryFrom<String> for InstrumentId
impl TryFrom<String> for InstrumentId
impl Eq for InstrumentId
impl StructuralPartialEq for InstrumentId
Auto Trait Implementations§
impl Freeze for InstrumentId
impl RefUnwindSafe for InstrumentId
impl Send for InstrumentId
impl Sync for InstrumentId
impl Unpin for InstrumentId
impl UnsafeUnpin for InstrumentId
impl UnwindSafe for InstrumentId
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)