#[non_exhaustive]pub struct FlossCommand { /* private fields */ }Expand description
一次具体的 FLOSS 调用(可透传任意参数,保证“全功能”覆盖)。
Implementations§
Source§impl FlossCommand
impl FlossCommand
Sourcepub fn command_line(&self) -> CommandLine
pub fn command_line(&self) -> CommandLine
返回本次调用的命令行信息(含 -- 与 sample)。
Sourcepub async fn run(self) -> Result<FlossOutput>
pub async fn run(self) -> Result<FlossOutput>
执行命令并检查退出码(非 0 返回 FlossError::NonZeroExit)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当进程退出码非 0 时,返回
FlossError::NonZeroExit(包含 stdout/stderr)。
Sourcepub async fn run_allow_exit_codes<Codes>(
self,
codes: Codes,
) -> Result<FlossOutput>
pub async fn run_allow_exit_codes<Codes>( self, codes: Codes, ) -> Result<FlossOutput>
执行命令并允许指定退出码视为成功。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当退出码不在允许列表时,返回
FlossError::NonZeroExit(包含 stdout/stderr)。
Sourcepub async fn run_json<Output>(self) -> Result<Output>where
Output: DeserializeOwned,
pub async fn run_json<Output>(self) -> Result<Output>where
Output: DeserializeOwned,
以 JSON 方式运行 FLOSS 并反序列化输出。
- 若未显式传入
-j/--json,会自动补上-j。 - 该方法默认会检查退出码(非 0 直接返回错误)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当进程退出码非 0 时,返回
FlossError::NonZeroExit(包含 stdout/stderr)。 - 当 stdout 不是有效 JSON 时,返回
FlossError::Json。
Sourcepub async fn run_results(self) -> Result<ResultDocument>
pub async fn run_results(self) -> Result<ResultDocument>
以 JSON 方式运行 FLOSS 并解析为 ResultDocument。
- 若未显式传入
-j/--json,会自动补上-j。 - 该方法默认会检查退出码(非 0 直接返回错误)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当进程退出码非 0 时,返回
FlossError::NonZeroExit(包含 stdout/stderr)。 - 当 stdout 不是有效 JSON 时,返回
FlossError::Json。
Sourcepub async fn run_raw(self) -> Result<FlossOutput>
pub async fn run_raw(self) -> Result<FlossOutput>
执行命令并返回输出(不检查退出码)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当超时且无法终止进程时,返回
FlossError::TimedOutKillFailed。
Sourcepub async fn run_raw_limited(
self,
max_bytes: usize,
) -> Result<FlossOutputLimited>
pub async fn run_raw_limited( self, max_bytes: usize, ) -> Result<FlossOutputLimited>
执行命令并以固定上限读取 stdout/stderr(不检查退出码)。
- 若输出超过
max_bytes,仅保留前max_bytes字节,剩余字节会被丢弃。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当超过超时时间时,返回
FlossError::TimedOut(stdout/stderr 可能被截断)。 - 当超时且无法终止进程时,返回
FlossError::TimedOutKillFailed。
Sourcepub async fn run_inherit(self) -> Result<ExitStatus>
pub async fn run_inherit(self) -> Result<ExitStatus>
执行命令并将 stdout/stderr 直连终端(不检查退出码)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当超过超时时间时,返回
FlossError::TimedOut(stderr/stdout 为空)。 - 当超时且无法终止进程时,返回
FlossError::TimedOutKillFailed(stderr/stdout 为空)。
Sourcepub async fn run_inherit_checked(self) -> Result<ExitStatus>
pub async fn run_inherit_checked(self) -> Result<ExitStatus>
执行命令并将 stdout/stderr 直连终端(退出码非 0 返回错误)。
§Errors
- 当启动进程失败时,返回
FlossError::Io。 - 当超过超时时间时,返回
FlossError::TimedOut(stderr/stdout 为空)。 - 当超时且无法终止进程时,返回
FlossError::TimedOutKillFailed(stderr/stdout 为空)。 - 当退出码非 0 时,返回
FlossError::NonZeroExit(stderr/stdout 为空)。
Sourcepub fn spawn(self) -> Result<Child>
pub fn spawn(self) -> Result<Child>
启动子进程并将 stdout/stderr 直连终端,返回 Child 由调用方管理。
注意:该方法不处理超时,由调用方自行管理。
§Errors
- 当启动进程失败时,返回
FlossError::Io。
Sourcepub fn spawn_piped(self) -> Result<Child>
pub fn spawn_piped(self) -> Result<Child>
启动子进程并将 stdout/stderr 设为 piped,返回 Child 由调用方管理。
注意:该方法不处理超时,由调用方自行管理。
§Errors
- 当启动进程失败时,返回
FlossError::Io。
Sourcepub fn sample<Sample>(self, sample: Sample) -> Self
pub fn sample<Sample>(self, sample: Sample) -> Self
设置样本(FLOSS 的位置参数 sample)。
内部会自动插入 --,避免样本路径以 - 开头时被误解析为参数。
Sourcepub const fn with_timeout(self, timeout: Duration) -> Self
pub const fn with_timeout(self, timeout: Duration) -> Self
设置执行超时:超过该时间会尝试终止子进程并返回 FlossError::TimedOut。
Trait Implementations§
Source§impl Clone for FlossCommand
impl Clone for FlossCommand
Source§fn clone(&self) -> FlossCommand
fn clone(&self) -> FlossCommand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FlossCommand
impl RefUnwindSafe for FlossCommand
impl Send for FlossCommand
impl Sync for FlossCommand
impl Unpin for FlossCommand
impl UnwindSafe for FlossCommand
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