Change functions to return an optional JoinHandle

This commit is contained in:
Elias Schriefer 2020-09-14 20:13:52 +02:00
parent f0066c8e76
commit bb9bfd3b62

View File

@ -1,10 +1,11 @@
use tokio::task::JoinHandle;
use super::errors::ServiceError; use super::errors::ServiceError;
pub trait org_ddnss_sfs_mc_Service { pub trait org_ddnss_sfs_mc_Service {
fn start(&mut self) -> Result<tokio::task::JoinHandle<()>, ServiceError>; fn start(&mut self) -> Result<Option<JoinHandle<()>>, ServiceError>;
fn stop(&mut self) -> Result<(), ServiceError>; fn stop(&mut self) -> Result<Option<JoinHandle<()>>, ServiceError>;
fn is_running(&self) -> bool; fn is_running(&self) -> bool;
fn restart(&mut self) -> Result<tokio::task::JoinHandle<()>, ServiceError> { fn restart(&mut self) -> Result<Option<JoinHandle<()>>, ServiceError> {
if self.is_running() { if self.is_running() {
self.stop()?; self.stop()?;
} }