Monocore

Struct Monocore 

Source
pub struct Monocore { /* private fields */ }
Expand description

The monocore configuration.

Implementations§

Source§

impl Monocore

Source

pub fn merge(&self, other: &Monocore) -> MonocoreResult<Monocore>

Merges two Monocore configurations, producing a new configuration that combines both. This is used for updating running configurations while maintaining consistency.

The merge follows these rules:

  • Services and groups from both configs are combined
  • If a service exists in both configs, the newer version (from other) takes precedence
  • If a group exists in both configs, the newer version takes precedence
  • Validates that the merged configuration maintains consistency
Source

pub fn get_changed_services<'a>( &'a self, other: &'a Monocore, ) -> Vec<&'a Service>

Gets a list of services that were either added or modified in the merged configuration compared to the original configuration.

A service is considered modified if either:

  • The service itself has changed
  • The group the service belongs to has changed
§Returns

A vector of references to services that were either added or modified

Source§

impl Monocore

Source

pub const MAX_DEPENDENCY_DEPTH: usize = 32usize

The maximum service dependency chain length.

Source

pub fn builder() -> MonocoreBuilder

Creates a new builder for a Monocore configuration.

This builder provides a fluent interface for configuring and creating a Monocore configuration. The builder validates the configuration during build to ensure it is valid.

§Examples
use monocore::config::Monocore;

let monocore = Monocore::builder()
    .services(vec![])
    .groups(vec![])
    .build()
    .unwrap();
Source

pub fn default_num_vcpus() -> u8

Returns the default number of vCPUs.

Source

pub fn default_ram_mib() -> u32

Returns the default amount of RAM in MiB.

Source

pub fn get_group(&self, group_name: &str) -> Option<&Group>

Get a group by name in this configuration

Source

pub fn get_groups(&self) -> &[Group]

Get all groups in this configuration

Source

pub fn get_service(&self, service_name: &str) -> Option<&Service>

Get a service by name in this configuration

Source

pub fn get_services(&self) -> &[Service]

Get all services in this configuration

Source

pub fn remove_services(&mut self, names: &[String])

Removes specified services from the configuration in place. If service_names is None, removes all services. Groups are preserved unless all services are removed.

§Arguments
  • names - The set of service names to remove.
Source

pub fn get_ordered_services(&self) -> Vec<&Service>

Gets all services ordered by their dependencies, such that dependencies come before dependents. This is useful for starting services in the correct order.

§Returns

A vector of service references ordered by dependencies (dependencies first)

§Note

This method assumes the configuration has already been validated (no circular dependencies). The validation is performed during configuration building.

Source

pub fn get_group_for_service<'a>( &'a self, service_name: &str, ) -> MonocoreResult<Option<&'a Group>>

Gets the group for a service by name.

§Arguments
  • service_name - The name of the service to get the group for
§Returns
  • Ok(Some(group)) if the service exists and has a valid group configuration
  • Ok(None) if the service exists but:
    • Has no group specified
    • References a non-existent group
  • Err(_) if the service doesn’t exist
Source§

impl Monocore

Source

pub fn validate(&self) -> MonocoreResult<()>

Performs comprehensive validation of the Monocore configuration. This includes checking for:

  • Unique service and group names
  • Valid group references
  • Valid volume and environment references
  • Service dependencies
  • Service-specific configuration requirements
  • Circular dependencies in the service graph
  • Volume conflicts between groups
  • Port conflicts within groups
Source

pub fn check_circular_dependencies(&self) -> MonocoreResult<()>

Detects circular dependencies in the service dependency graph. A circular dependency occurs when services form a dependency cycle, which would prevent proper service startup ordering.

Trait Implementations§

Source§

impl Clone for Monocore

Source§

fn clone(&self) -> Monocore

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Monocore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Monocore

Source§

fn default() -> Monocore

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Monocore

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Monocore

Source§

fn eq(&self, other: &Monocore) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Monocore

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Monocore

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,