Skip to main content

harmos_sdk/operations/
instances.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16use harmos_domain::operations::instance::{Id, Status};
17use std::{future::Future, pin::Pin, sync::Arc};
18
19/* === Constants === */
20
21/* === Macros === */
22
23/* === Type Aliases === */
24
25pub type Changed<'a> = Pin<Box<dyn Future<Output = bool> + Send + 'a>>;
26
27/* === Structs === */
28
29#[derive(Clone)]
30pub struct InstanceAccess(pub Arc<dyn Instances>);
31
32/* === Enums === */
33
34/* === Traits === */
35
36pub trait Instances: Send + Sync {
37    fn owned(&self, id: Id) -> Option<Arc<dyn InstanceControl>>;
38}
39pub trait InstanceControl: Send + Sync {
40    fn status(&self) -> Status;
41    fn cancel(&self);
42    fn subscribe(&self) -> Box<dyn InstanceChanges>;
43}
44pub trait InstanceChanges: Send {
45    fn current(&mut self) -> Status;
46    fn changed(&mut self) -> Changed<'_>;
47}
48
49/* === Implementations === */
50
51/* === Public Functions === */
52
53/* === Private Functions === */
54
55/* === Tests === */