acktor_ipc/node/
command.rs1use std::fmt::{self, Debug};
5use std::marker::PhantomData;
6
7use acktor::{ActorId, Address, Message};
8
9use crate::actor_handle::ActorHandle;
10use crate::errors::NodeError;
11use crate::ipc_method::{IpcConnection, IpcListener};
12use crate::remote_actor::RemoteActor;
13use crate::remote_address::RemoteAddress;
14use crate::session::{Session, SessionHandle};
15
16type Result<T> = std::result::Result<T, NodeError>;
17
18#[derive(Message)]
23#[result_type(bool)]
24pub struct AddListener<L>(pub L)
25where
26 L: IpcListener;
27
28impl<L> Debug for AddListener<L>
29where
30 L: IpcListener,
31{
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 f.debug_tuple(&format!("{}", acktor::utils::ShortName::of::<Self>()))
34 .field(&format_args!("{}", self.0.local_endpoint()))
35 .finish()
36 }
37}
38
39#[derive(Debug, Message)]
43#[result_type(bool)]
44pub struct RemoveListener(pub String);
45
46#[derive(Message)]
48#[result_type(bool)]
49pub struct AddActor<A>(pub Address<A>)
50where
51 A: RemoteActor;
52
53impl<A> Debug for AddActor<A>
54where
55 A: RemoteActor,
56{
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 f.debug_tuple(&format!("{}", acktor::utils::ShortName::of::<Self>()))
59 .field(&format_args!("{}", self.0.index()))
60 .finish()
61 }
62}
63
64#[derive(Debug, Message)]
66#[result_type(bool)]
67pub struct RemoveActor(pub ActorId);
68
69#[derive(Message)]
81#[result_type(Result<Address<Session>>)]
82pub struct Connect<C>
83where
84 C: IpcConnection,
85{
86 pub endpoint: String,
87 pub session_label: Option<String>,
88 pub _phantom: PhantomData<fn() -> C>,
89}
90
91impl<C> Debug for Connect<C>
92where
93 C: IpcConnection,
94{
95 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
96 f.debug_tuple(&format!("{}", acktor::utils::ShortName::of::<Self>()))
97 .field(&self.endpoint)
98 .field(&self.session_label)
99 .finish()
100 }
101}
102
103impl<C> Connect<C>
104where
105 C: IpcConnection,
106{
107 pub fn new(endpoint: String, session_label: Option<String>) -> Self {
109 Self {
110 endpoint,
111 session_label,
112 _phantom: PhantomData,
113 }
114 }
115}
116
117#[derive(Debug, Message)]
123#[result_type(Result<RemoteAddress>)]
124pub struct CreateRemoteActor {
125 pub session: SessionHandle,
126 pub label: String,
127 pub r#type: String,
128 pub config: String,
129}
130
131#[derive(Debug, Message)]
133#[result_type(Result<RemoteAddress>)]
134pub struct GetRemoteActor {
135 pub session: SessionHandle,
136 pub actor: ActorHandle,
137}