pub struct AssetInfo {
pub id: String,
pub price: Decimal,
pub timestamp: i64,
}Expand description
Represents price and timestamp information for a specific asset.
AssetInfo stores the essential information about an asset’s current state,
including its unique identifier, price, and the timestamp of when the information
was last updated. This structure is used throughout the system for storing,
transmitting, and displaying asset information.
The structure implements various traits for serialization, deserialization, and display, making it compatible with different storage backends and presentation formats.
§Examples
use rust_decimal::Decimal;
use bothan_lib::types::AssetInfo;
// Create a new asset information entry
let asset = AssetInfo::new(
"BTC-USD".to_string(),
Decimal::new(3950000, 2), // $39,500.00
1634567890000, // Unix timestamp in milliseconds
);
// Access the asset information
assert_eq!(asset.id, "BTC-USD");
assert_eq!(asset.price.to_string(), "39500.00");Fields§
§id: StringUnique identifier for the asset, typically in the format of a trading pair (e.g., “BTC-USD”).
price: DecimalCurrent price of the asset represented as a high-precision decimal.
timestamp: i64Unix timestamp (in milliseconds) when the asset information was last updated.
Implementations§
Trait Implementations§
Source§impl<Context> Decode<Context> for AssetInfo
Custom binary decoding implementation for efficient deserialization.
impl<Context> Decode<Context> for AssetInfo
Custom binary decoding implementation for efficient deserialization.
This implementation ensures that AssetInfo can be efficiently decoded from a binary format, which is important when retrieving from storage or receiving over the network.
Source§impl<'de> Deserialize<'de> for AssetInfo
impl<'de> Deserialize<'de> for AssetInfo
Source§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>,
Source§impl Encode for AssetInfo
Custom binary encoding implementation for efficient serialization.
impl Encode for AssetInfo
Custom binary encoding implementation for efficient serialization.
This implementation ensures that AssetInfo can be efficiently encoded in a binary format, which is important for storage and network transmission.
impl StructuralPartialEq for AssetInfo
Auto Trait Implementations§
impl Freeze for AssetInfo
impl RefUnwindSafe for AssetInfo
impl Send for AssetInfo
impl Sync for AssetInfo
impl Unpin for AssetInfo
impl UnwindSafe for AssetInfo
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request