1mod owner;
13
14pub use crate::error::Error;
17pub use harmos_domain::plugin::*;
18pub use owner::{Owner, Table};
19
20use std::future::Future;
24use std::pin::Pin;
25use std::sync::Arc;
26
27use crate::operations::{ServingError, WireTable};
31use harmos_domain::model::operations::lifecycle;
32
33pub trait Context: crate::lifecycle::Context<Configuration = WireTable> {
46 fn assign_operations(&self, bytes: &[u8]) -> Result<(), ServingError>;
47 fn with_generation(&self, token: [u8; 32]) -> Self;
48}
49
50pub trait Plugin: crate::Lifecycle<Context: Context> + lifecycle::Policy + Sync {
51 const CATALOGS: &'static [crate::operations::Catalog];
52
53 fn register(_registrar: &mut crate::Registrar) -> Result<(), crate::RegistrationError> {
54 Ok(())
55 }
56
57 fn attachment(&self) -> Option<Arc<dyn Attachment<Self::Context>>> {
58 None
59 }
60}
61
62pub trait Attachment<C>: Send + Sync + 'static {
63 #[doc(hidden)]
64 fn bind(self: Arc<Self>, table: &mut WireTable) -> Result<(), ServingError>;
65
66 fn observers(&self) -> Vec<crate::inventory::observers::Declaration>;
67 fn quiesce(&self) -> Pin<Box<dyn Future<Output = Result<(), ServingError>> + Send + '_>>;
68}
69
70impl crate::lifecycle::Context for () {
73 type Configuration = WireTable;
74}
75
76impl Context for () {
77 fn assign_operations(&self, bytes: &[u8]) -> Result<(), ServingError> {
78 if bytes.is_empty() { Ok(()) } else { Err(ServingError::Catalog) }
79 }
80 fn with_generation(&self, _: [u8; 32]) -> Self {}
81}
82
83