pub struct EnabledServices { /* private fields */ }Expand description
Set of enabled services in a topology
Provides information about which services are enabled in the topology. This is needed because network assignments depend on inter-service relationships (e.g., Tracker needs Metrics network only if Prometheus exists).
§Design
Uses a HashSet<Service> internally, following the Open/Closed principle:
adding new services doesn’t require adding new fields or methods.
§Examples
use torrust_tracker_deployer_lib::domain::topology::{EnabledServices, Service};
// Create with specific services enabled
let enabled = EnabledServices::from(&[Service::Prometheus, Service::Grafana]);
assert!(enabled.has(Service::Prometheus));
assert!(enabled.has(Service::Grafana));
assert!(!enabled.has(Service::Caddy));
assert!(!enabled.has(Service::MySQL));Implementations§
Source§impl EnabledServices
impl EnabledServices
Sourcepub fn from(services: &[Service]) -> Self
pub fn from(services: &[Service]) -> Self
Creates a new set of enabled services from a slice
This is the primary constructor. The services slice represents which optional services are present in the deployment.
§Examples
use torrust_tracker_deployer_lib::domain::topology::{EnabledServices, Service};
let enabled = EnabledServices::from(&[Service::Prometheus, Service::MySQL]);
assert!(enabled.has(Service::Prometheus));
assert!(enabled.has(Service::MySQL));Sourcepub fn has(&self, service: Service) -> bool
pub fn has(&self, service: Service) -> bool
Checks if a specific service is enabled
§Examples
use torrust_tracker_deployer_lib::domain::topology::{EnabledServices, Service};
let enabled = EnabledServices::from(&[Service::Caddy]);
assert!(enabled.has(Service::Caddy));
assert!(!enabled.has(Service::MySQL));Trait Implementations§
Source§impl Clone for EnabledServices
impl Clone for EnabledServices
Source§impl Debug for EnabledServices
impl Debug for EnabledServices
Auto Trait Implementations§
impl Freeze for EnabledServices
impl RefUnwindSafe for EnabledServices
impl Send for EnabledServices
impl Sync for EnabledServices
impl Unpin for EnabledServices
impl UnsafeUnpin for EnabledServices
impl UnwindSafe for EnabledServices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request