#![allow(
clippy::missing_errors_doc,
clippy::missing_panics_doc,
reason = "errors and panics are documented on the canonical facade methods"
)]
use nautilus_model::identifiers::ActorId;
use super::DataActorNative;
use crate::clock::ClockApi;
#[doc(hidden)]
#[diagnostic::on_unimplemented(
message = "this DataActor method requires a DataActorBinding implementation"
)]
pub trait DataActorBinding {
fn binding_actor_id(&self) -> ActorId;
fn binding_clock(&self) -> ClockApi<'_>;
}
impl<T> DataActorBinding for T
where
T: DataActorNative,
{
fn binding_actor_id(&self) -> ActorId {
self.core().actor_id()
}
fn binding_clock(&self) -> ClockApi<'_> {
self.core().clock_api()
}
}
#[cfg(test)]
mod tests {
use rstest::rstest;
use crate::actor::DataActor;
#[rstest]
fn actor_behavior_requires_no_native_core() {
assert_data_actor::<PortableActor>();
}
fn assert_data_actor<T: DataActor>() {
let _: fn(&mut T) -> anyhow::Result<()> = T::on_start;
}
#[derive(Debug)]
struct PortableActor;
impl DataActor for PortableActor {}
}