use std::sync::Arc; use crate::{ instance_manager::NetworkInstanceManager, proto::{rpc_impl::service_registry::ServiceRegistry, web::DeviceOsInfo}, rpc_service::api::register_api_rpc_service, web_client::WebClientHooks, }; pub struct Controller { token: String, machine_id: uuid::Uuid, hostname: String, device_os: DeviceOsInfo, manager: Arc, hooks: Arc, } impl Controller { pub fn new( token: String, machine_id: uuid::Uuid, hostname: String, device_os: DeviceOsInfo, manager: Arc, hooks: Arc, ) -> Self { Controller { token, machine_id, hostname, device_os, manager, hooks, } } pub fn list_network_instance_ids(&self) -> Vec { self.manager.list_network_instance_ids() } pub fn token(&self) -> String { self.token.clone() } pub fn hostname(&self) -> String { self.hostname.clone() } pub fn machine_id(&self) -> uuid::Uuid { self.machine_id } pub fn device_os(&self) -> DeviceOsInfo { self.device_os.clone() } pub fn register_api_rpc_service(&self, registry: &ServiceRegistry) { register_api_rpc_service(&self.manager, registry, Some(self.hooks.clone())); } pub(super) fn notify_manager_stopping(&self) { self.manager.notify_stop_check(); } }