pub struct ExecHook { /* private fields */ }Expand description
外部命令执行钩子
在下载完成后执行指定的外部命令,并将下载相关信息作为环境变量注入。 支持的环境变量:
ARIA2_GID: 任务组 IDARIA2_PATH: 文件路径ARIA2_STATUS: 下载状态ARIA2_ERROR: 错误信息(如有)ARIA2_DOWNLOADED_BYTES: 已下载字节数ARIA2_UPLOADED_BYTES: 已上传字节数ARIA2_DOWNLOAD_SPEED: 下载速度ARIA2_UPLOAD_SPEED: 上传速度
Implementations§
Trait Implementations§
Source§impl PostDownloadHook for ExecHook
impl PostDownloadHook for ExecHook
Source§fn on_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
context: &'life1 HookContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
context: &'life1 HookContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
执行外部命令
通过 shell 执行配置的命令,注入 aria2 相关环境变量。 非 zero 退出码会被视为执行失败。
Source§fn on_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
context: &'life1 HookContext,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
context: &'life1 HookContext,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
在下载错误时执行命令
与 on_complete 类似,但状态会被设置为 “error”。
Auto Trait Implementations§
impl Freeze for ExecHook
impl RefUnwindSafe for ExecHook
impl Send for ExecHook
impl Sync for ExecHook
impl Unpin for ExecHook
impl UnsafeUnpin for ExecHook
impl UnwindSafe for ExecHook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more