blob: d10e436f6dc10d861b86f08aee836c6632c3bd96 (
plain)
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
|
use crate::error::Result;
use crate::facility::FacilityType;
use std::sync::{ Arc, Mutex };
use std::time::Duration;
pub use time::TimeModule;
pub mod time;
/* As with Facility, we need a separate trait for the stuff that wouldn't be
* dyn-compatible.
*/
pub trait CreatableModule: Module + Sized {
const REQUIRED_FACILITIES: FacilityType;
fn new() -> Result<Self>;
/* The only way to coerce to dyn is to return as it! */
fn as_box<'a>(self) -> Box<dyn Module + 'a>
where Self: 'a
{
Box::new(self)
}
}
pub trait Module {
fn format(&mut self) -> String;
fn sleep_duration(&self) -> Option<Duration>;
}
|