Skip to main content

ProcessManager

Trait ProcessManager 

Source
pub trait ProcessManager: Send + Sync {
    // Required methods
    fn start<'life0, 'async_trait>(
        &'life0 self,
        command: String,
        args: Vec<String>,
        working_dir: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 self,
        pid: u32,
        force: bool,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_info<'life0, 'async_trait>(
        &'life0 self,
        pid: u32,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<Option<ProcessInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_state<'life0, 'async_trait>(
        &'life0 self,
        pid: u32,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<ProcessState>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_alive<'life0, 'async_trait>(
        &'life0 self,
        pid: u32,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn wait<'life0, 'async_trait>(
        &'life0 self,
        pid: u32,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<i32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ProcessInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_by_state<'life0, 'async_trait>(
        &'life0 self,
        state: ProcessState,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ProcessInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn signal<'life0, 'async_trait>(
        &'life0 self,
        pid: u32,
        signal: ProcessSignal,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

进程管理器 trait

定义进程管理核心接口。

Required Methods§

Source

fn start<'life0, 'async_trait>( &'life0 self, command: String, args: Vec<String>, working_dir: Option<String>, ) -> Pin<Box<dyn Future<Output = Layer3Result<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

启动新进程

§Arguments
  • command - 命令行
  • args - 参数
  • working_dir - 工作目录
§Returns
  • u32 - 进程 PID
Source

fn stop<'life0, 'async_trait>( &'life0 self, pid: u32, force: bool, ) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

停止进程

§Arguments
  • pid - 进程 PID
  • force - 是否强制终止
Source

fn get_info<'life0, 'async_trait>( &'life0 self, pid: u32, ) -> Pin<Box<dyn Future<Output = Layer3Result<Option<ProcessInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取进程信息

Source

fn get_state<'life0, 'async_trait>( &'life0 self, pid: u32, ) -> Pin<Box<dyn Future<Output = Layer3Result<ProcessState>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取进程状态

Source

fn is_alive<'life0, 'async_trait>( &'life0 self, pid: u32, ) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

检查进程是否存活

Source

fn wait<'life0, 'async_trait>( &'life0 self, pid: u32, ) -> Pin<Box<dyn Future<Output = Layer3Result<i32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

等待进程结束

Source

fn list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ProcessInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

列出所有管理的进程

Source

fn list_by_state<'life0, 'async_trait>( &'life0 self, state: ProcessState, ) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ProcessInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

列出指定状态的进程

Source

fn signal<'life0, 'async_trait>( &'life0 self, pid: u32, signal: ProcessSignal, ) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

发送信号到进程

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§