use serde::{Deserialize, Serialize};
#[derive(
Debug, Default, Clone, Copy, PartialEq, Eq, Deserialize, Serialize,
)]
#[serde(rename_all = "lowercase")]
pub enum Scope {
Master,
#[default]
#[serde(alias = "workers")]
Worker,
#[serde(alias = "fleet", alias = "both")]
Any,
}
impl Scope {
#[allow(non_upper_case_globals)]
pub const Fleet: Self = Self::Any;
#[allow(non_upper_case_globals)]
pub const Workers: Self = Self::Worker;
pub fn includes(
self,
role: impl Into<Self>,
) -> bool {
let role = role.into();
self == Self::Any || role == Self::Any || self == role
}
}
pub trait Scoped {
fn scope(&self) -> Scope;
}
pub mod dispatch;
pub use dispatch::{
Dispatch, DispatchPolicy, DispatchRequest, Dispatched, Dispatcher,
InstancePlacement, ServiceExecution,
};
#[cfg(test)]
#[path = "../tests/fleet/scope.rs"]
mod tests;