nautilus_model/ffi/data/
prices.rs1use std::{
17 collections::hash_map::DefaultHasher,
18 ffi::c_char,
19 hash::{Hash, Hasher},
20};
21
22use nautilus_core::ffi::string::str_to_cstr;
23
24use crate::{data::MarkPriceUpdate, identifiers::InstrumentId, types::Price};
25
26#[unsafe(no_mangle)]
27#[cfg_attr(feature = "high-precision", allow(improper_ctypes_definitions))]
28pub extern "C" fn mark_price_update_new(
29 instrument_id: InstrumentId,
30 value: Price,
31 ts_event: u64,
32 ts_init: u64,
33) -> MarkPriceUpdate {
34 MarkPriceUpdate::new(instrument_id, value, ts_event.into(), ts_init.into())
35}
36
37#[unsafe(no_mangle)]
38pub extern "C" fn mark_price_update_eq(lhs: &MarkPriceUpdate, rhs: &MarkPriceUpdate) -> u8 {
39 u8::from(lhs == rhs)
40}
41
42#[unsafe(no_mangle)]
43pub extern "C" fn mark_price_update_hash(value: &MarkPriceUpdate) -> u64 {
44 let mut hasher = DefaultHasher::new();
45 value.hash(&mut hasher);
46 hasher.finish()
47}
48
49#[unsafe(no_mangle)]
50pub extern "C" fn mark_price_update_to_cstr(value: &MarkPriceUpdate) -> *const c_char {
51 str_to_cstr(&value.to_string())
52}