47 lines
1012 B
Rust
47 lines
1012 B
Rust
|
|
//! Value contracts for the single-worker actor prototype.
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||
|
|
pub struct ActorId(pub u64);
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||
|
|
pub struct ImplementationId(pub u64);
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||
|
|
pub struct MailboxId(pub u64);
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||
|
|
pub struct Message {
|
||
|
|
pub kind: i64,
|
||
|
|
pub value: i64,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||
|
|
pub enum Status {
|
||
|
|
Idle,
|
||
|
|
Running,
|
||
|
|
Awaiting,
|
||
|
|
Stopped,
|
||
|
|
Failed(String),
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone)]
|
||
|
|
pub struct ActorSnapshot {
|
||
|
|
pub id: ActorId,
|
||
|
|
pub mailbox: MailboxId,
|
||
|
|
pub implementation: ImplementationId,
|
||
|
|
pub incarnation: u64,
|
||
|
|
pub state: i64,
|
||
|
|
pub status: Status,
|
||
|
|
pub queued: Vec<Message>,
|
||
|
|
pub reserved: Option<Message>,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone)]
|
||
|
|
pub enum Event {
|
||
|
|
Spawned(ActorId),
|
||
|
|
Committed(ActorId),
|
||
|
|
Failed(ActorId, String),
|
||
|
|
Stopped(ActorId),
|
||
|
|
Restarted(ActorId),
|
||
|
|
}
|