Rust

service

Module

Services group the actions of one server type; modules group services.

Contents

use utopia_platform::Module;
Rust
pub struct Module

Services by key, also listed by type.

Rust
use utopia_platform::{Module, Service, ServiceType};

let mut module = Module::new();
module.add_service("api", Service::new(ServiceType::HTTP)).add_service("tasks", Service::new(ServiceType::TASK));
assert_eq!(module.services_by_type(&ServiceType::HTTP).len(), 1);
assert_eq!(module.service("missing").unwrap_err().to_string(), "Service missing not found");
use utopia_platform::Service;
Rust
pub struct Service

The actions of one server type, by key (the CLI task name, the worker name).

Rust
use utopia_platform::{Action, Service, ServiceType};

let mut service = Service::new(ServiceType::TASK);
service.add_action("build", Action::new()).add_action("clean", Action::new());
service.remove_action("clean");
assert_eq!(service.actions().keys().collect::<Vec<_>>(), ["build"]);
assert!(service.action("clean").is_none());
use utopia_platform::ServiceType;
Rust
pub struct ServiceType(Cow<'static, str>)

The server a service's actions register on. Any other name is kept, and crate::Platform::init refuses it.