#[non_exhaustive]pub struct FlossCli { /* private fields */ }Expand description
FLOSS CLI 入口配置(可执行文件名/路径、基础参数、工作目录与环境变量)。
Implementations§
Source§impl FlossCli
impl FlossCli
Sourcepub fn command(&self) -> FlossCommand
pub fn command(&self) -> FlossCommand
构建一次调用(可继续追加参数、可选追加样本路径),最后用 run/run_raw/run_json 执行。
Sourcepub async fn detect() -> Result<Self>
pub async fn detect() -> Result<Self>
自动探测调用方式:
- 若设置
FLOSS_EXE,优先使用该值作为可执行文件; - 若设置
FLOSS_PYTHON,优先尝试FLOSS_PYTHON {FLOSS_PYTHON_ARGS} -m floss -h; - 否则检测 PATH 中是否存在
floss.exe(Windows)或floss(其他系统); - 最后尝试 Python:Windows 依次尝试
python/python3/py -3,其他系统依次尝试python3/python。
§Errors
- 当既找不到可执行的
floss,也找不到可运行python -m floss的 Python 时,返回FlossError::AutoDetectFailed。
Sourcepub async fn help(&self) -> Result<String>
pub async fn help(&self) -> Result<String>
等价于执行 floss -h,返回 stdout。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当 stdout 不是有效 UTF-8 时,返回
FlossError::Utf8。
Sourcepub async fn help_all(&self) -> Result<String>
pub async fn help_all(&self) -> Result<String>
等价于执行 floss -H,返回 stdout(包含高级参数)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当 stdout 不是有效 UTF-8 时,返回
FlossError::Utf8。
Sourcepub fn python_module<Python>(python: Python) -> Self
pub fn python_module<Python>(python: Python) -> Self
通过 python -m floss 方式调用(适合只安装了 Python 包、没有独立 floss 可执行文件的场景)。
Sourcepub async fn version(&self) -> Result<String>
pub async fn version(&self) -> Result<String>
等价于执行 floss --version,返回 stdout。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当 stdout 不是有效 UTF-8 时,返回
FlossError::Utf8。
Sourcepub fn with_current_dir<Dir>(self, dir: Dir) -> Self
pub fn with_current_dir<Dir>(self, dir: Dir) -> Self
设置工作目录(Command::current_dir)。
Sourcepub const fn with_timeout(self, timeout: Duration) -> Self
pub const fn with_timeout(self, timeout: Duration) -> Self
设置执行超时:超过该时间会尝试终止子进程并返回 FlossError::TimedOut。
若无法终止子进程,则返回 FlossError::TimedOutKillFailed。
若无法终止子进程,则返回 FlossError::TimedOutKillFailed。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlossCli
impl RefUnwindSafe for FlossCli
impl Send for FlossCli
impl Sync for FlossCli
impl Unpin for FlossCli
impl UnwindSafe for FlossCli
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