Pseudocode & layout for Actors

main
~erin 2023-04-20 18:08:37 -04:00
parent a3635a465f
commit 1389ca88cf
Signed by untrusted user: erin
GPG Key ID: 9A8E308CEFA37A47
2 changed files with 78 additions and 1 deletions

View File

@ -5,7 +5,7 @@
# Developer Guide # Developer Guide
- [Development](development/README.md) - [Development](development/README.md)
- [Understanding the Design Goals](development/design/README.md) - [Understanding the Design Goals](development/design/README.md)
- [Actor System]() - [Actor System](development/design/actor.md)
- [Security Features](development/design/security.md) - [Security Features](development/design/security.md)
- [Microkernel](development/design/kernel.md) - [Microkernel](development/design/kernel.md)
- [GUI](development/design/gui.md) - [GUI](development/design/gui.md)

View File

@ -1,4 +1,81 @@
# Actor System # Actor System
```admonish question title="Why?"
**Actors** work as an abstraction over data storage and messaging.
It allows for all systems *(GUI, Programs, etc.)* to work together, and rely on the same features.
It reduces work of implementation, and all implementations can use the functions.
```
## Features
- Petnames
- **OCAP** security
- **HMAC** message verification
```rust
// Different possible types of actors (more to be added)
enum ActorType {
GUI(Widget),
ProgramInterface,
}
// Possible states an actor can be in
enum ActorState {
Receive,
Send,
Work,
Idle,
}
// Cryptographic keypair
struct KeyPair {
privkey: u128,
pubkey: u128,
}
// The actor itself
struct Actor<D: DataInterface> {
petname: Option<String>, // Human-meaningful petname (explored further down)
uuid: Uuid, // Unique identifier
namespace: Uuid, // Parent namespace of this actor
actor_type: ActorType,
state: ActorState,
keys: Option<KeyPair>, // Cryptographic keypair
creation_date: DateTime,
modified_date: DateTime,
data: Option<D>, // Optional data of the generic D type
}
impl Actor {
fn new(namespace: Uuid, a_type: ActorType) -> Self {
Actor {
petname: None,
uuid: Uuid::new(),
namespace: namespace,
actor_type: a_type,
state: ActorState::Idle,
keys: None,
creation_date:: now(),
modified_date: now(),
data: None,
}
};
}
impl KeyPair {
fn generate_keypair(&mut self) -> Self;
fn get_pubkey(&self) -> u128;
fn sign(&self, &[u8]) -> Result<&[u8], Error>;
fn verify_signature(&[u8], u128) -> Result<(), Error>;
}
trait FilesystemInterface { // Interfacing with the filesystem
fn read(&mut self) -> Result<(), Error>; // Read the data from the disk into the Actor using the Uuid as a search key
fn write(&self) -> Result<(), Error>; // Write the data to the disk using the Uuid as a key
}
trait DataInterface { // Necessary data functions
fn to_bytes(&self) -> Result<&[u8], Error>; // Convert the data into a byte array
}
```
## OCAP ## OCAP
**TODO** **TODO**