1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#![warn(missing_docs)]
mod actors;
pub mod macros;
pub mod prelude;
mod protocol;
pub mod providers;
mod state;
use crate::actors::supervisor::RillSupervisor;
use anyhow::Error;
use rill_protocol::provider::EntryId;
use state::{RillState, RILL_STATE};
use thiserror::Error;
metacrate::meta!();
#[derive(Debug, Error)]
enum RillError {
#[error("alreary installed")]
AlreadyInstalled,
#[error("io error {0}")]
IoError(#[from] std::io::Error),
}
#[derive(Debug)]
pub struct Rill {
_scoped: meio::thread::ScopedRuntime,
}
impl Rill {
pub fn install(name: impl Into<EntryId>) -> Result<Self, Error> {
let (rx, state) = RillState::create();
RILL_STATE
.set(state)
.map_err(|_| RillError::AlreadyInstalled)?;
let actor = RillSupervisor::new(name.into(), rx);
let scoped = meio::thread::spawn(actor)?;
Ok(Self { _scoped: scoped })
}
}