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
use crateActorContext;
use crateActor;
use Error;
use UnwindSafe;
/// [Actor] can only be created from a Factory
///
/// This factory approach is necessary because of the restart behavior.
/// Without this factory we'd need to keep a `.clone()` of the initial Actor, which would force all Actor implementations to implement `Clone`.
///
/// # Examples
///
/// Basic usage:
///
/// ```rust
/// use std::error::Error;
/// use tyra::prelude::*;
///
/// struct TestActor {}
///
/// impl Actor for TestActor {}
///
/// struct TestFactory {}
///
/// impl ActorFactory<TestActor> for TestFactory {
/// fn new_actor(&mut self, _context: ActorContext<TestActor>) -> Result<TestActor, Box<dyn Error>> {
/// Ok(TestActor {})
/// }
/// }
/// ```