nautilus_common/actor/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3//  https://poseitrader.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16#![allow(unsafe_code)]
17
18use std::any::Any;
19
20use ustr::Ustr;
21
22pub mod data_actor;
23#[cfg(feature = "indicators")]
24pub(crate) mod indicators;
25pub mod registry;
26
27#[cfg(test)]
28mod tests;
29
30// Re-exports
31pub use data_actor::{DataActor, DataActorCore};
32
33pub trait Actor: Any {
34    /// The unique identifier for the actor.
35    fn id(&self) -> Ustr;
36    /// Handles the `msg`.
37    fn handle(&mut self, msg: &dyn Any);
38    /// Returns a reference to `self` as `Any`, for downcasting support.
39    fn as_any(&self) -> &dyn Any;
40    /// Returns a mutable reference to `self` as `Any`, for downcasting support.
41    ///
42    /// Default implementation simply coerces `&mut Self` to `&mut dyn Any`.
43    ///
44    /// # Note
45    ///
46    /// This method is not object-safe and thus only available on sized `Self`.
47    fn as_any_mut(&mut self) -> &mut dyn Any
48    where
49        Self: Sized,
50    {
51        self
52    }
53}