pub trait AsyncCommand<S, E, P>{
// Required methods
fn new<A, B>(
executable_path: &OsStr,
args: A,
process_type: P,
) -> Result<Self, E>
where A: IntoIterator<Item = B>,
B: AsRef<OsStr>;
async fn execute(&mut self, timeout: Option<Duration>) -> Result<S, E>;
}Expand description
Trait for types that can spawn and execute an OS process asynchronously.
The type parameter S is the success-status type (e.g. crate::pg_enums::PgServerStatus),
E is the error type, and P is the ProcessStatus implementation that
provides status/error mappings.
Self: Sized means this trait cannot be used as a dyn trait object. Use
the concrete AsyncCommandExecutor directly.
Required Methods§
Sourcefn new<A, B>(
executable_path: &OsStr,
args: A,
process_type: P,
) -> Result<Self, E>
fn new<A, B>( executable_path: &OsStr, args: A, process_type: P, ) -> Result<Self, E>
Creates and spawns a new OS process.
§Arguments
executable_path— Path to the executable (e.g.initdb,pg_ctl).args— Command-line arguments to pass to the executable.process_type— TheProcessStatusvalue describing this process.
§Errors
Returns E::error_type() if the process cannot be spawned.
Sourceasync fn execute(&mut self, timeout: Option<Duration>) -> Result<S, E>
async fn execute(&mut self, timeout: Option<Duration>) -> Result<S, E>
Waits for the process to finish, optionally enforcing a deadline.
Stdout and stderr are captured and forwarded to the log crate
(at info level) in background tasks.
§Arguments
timeout— IfSome(duration), the process is killed and an error is returned if it does not finish withinduration.Nonewaits indefinitely.
§Returns
The ProcessStatus::status_exit value on success.
§Errors
Returns ProcessStatus::timeout_error if the deadline is exceeded.
Returns ProcessStatus::error_type if the process exits with a
non-zero status.
Returns a wrapped error from ProcessStatus::wrap_error if waiting
on the process fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.