use std::{
any::Any,
fmt::{Debug, Display},
hash::Hash,
};
use nautilus_core::{UUID4, UnixNanos};
use nautilus_model::identifiers::TraderId;
use serde::{Deserialize, Serialize};
use ustr::Ustr;
#[repr(C)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(tag = "type")]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.model", from_py_object)
)]
pub struct ShutdownSystem {
pub trader_id: TraderId,
pub component_id: Ustr,
pub reason: Option<String>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
}
impl ShutdownSystem {
#[must_use]
pub fn new(
trader_id: TraderId,
component_id: Ustr,
reason: Option<String>,
command_id: UUID4,
ts_init: UnixNanos,
) -> Self {
Self {
trader_id,
component_id,
reason,
command_id,
ts_init,
}
}
pub fn as_any(&self) -> &dyn Any {
self
}
}
impl Display for ShutdownSystem {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}(trader_id={}, component_id={}, reason={:?}, command_id={})",
stringify!(ShutdownSystem),
self.trader_id,
self.component_id,
self.reason,
self.command_id,
)
}
}