constructor inlining

migrate
prplV 2025-05-28 16:42:50 +03:00
parent 3147c73006
commit ac0c3cb8c1
3 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,7 @@
}
impl FilesController {
#[inline(always)]
pub fn new(name: &str, triggers: EventHandlers) -> FilesController {
let name: Arc<str> = Arc::from(name);
Self {
@ -53,6 +54,7 @@
code_name : name.clone(),
}
}
#[inline(always)]
pub fn with_path(mut self, path: impl AsRef<Path>) -> anyhow::Result<FilesController> {
self.path = path.as_ref().to_string_lossy().into_owned();
self.watcher = {

View File

@ -61,6 +61,7 @@ pub mod v2 {
}
impl ProcessesController {
#[inline(always)]
pub fn new(name: &str, event_reader: MpscReciever<Events>) -> ProcessesController {
ProcessesController {
name : Arc::from(name),
@ -71,11 +72,11 @@ pub mod v2 {
negative_events : HashSet::new(),
}
}
#[inline(always)]
pub fn with_exe(mut self, bin: impl AsRef<Path>) -> ProcessesController {
self.bin = bin.as_ref().to_string_lossy().into_owned();
self
}
pub fn get_pid(&self) -> Pid {
self.pid
}

View File

@ -42,6 +42,7 @@ pub mod v2 {
}
impl ServicesController {
#[inline(always)]
pub fn new() -> ServicesController {
ServicesController {
name : String::new(),
@ -51,6 +52,7 @@ pub mod v2 {
event_registrator : EventHandlers::new(),
}
}
#[inline(always)]
pub fn with_access_name(
mut self,
hostname: &str,
@ -60,7 +62,7 @@ pub mod v2 {
self.access_url = Arc::from(access_url);
self
}
#[inline(always)]
pub fn with_params(
mut self,
conn_queue: ConnectionQueue,
@ -70,7 +72,6 @@ pub mod v2 {
self.event_registrator = event_reg;
self
}
pub fn get_access_url(hostname: &str, port: Option<&u32>) -> String {
format!("{}{}", hostname, port.map_or_else(|| "".to_string(), |p| format!(":{}", p)))
}