pub struct ProcessGuard { /* private fields */ }Expand description
RAII guard for process lifecycle management.
ProcessGuard automatically terminates the spawned process when dropped. This ensures proper cleanup even if errors occur during workflow execution.
The guard uses a shared boolean flag to track whether the process has already been terminated manually, preventing double-termination in Drop.
Implementations§
Source§impl ProcessGuard
impl ProcessGuard
Sourcepub fn terminate(&self) -> Result<(), ToolError>
pub fn terminate(&self) -> Result<(), ToolError>
Manually terminates the guarded process.
Sets the terminated flag to prevent double-termination in Drop.
§Returns
Ok(())if termination succeededErr(ToolError)if termination failed
§Example
use forge_agent::workflow::tools::ProcessGuard;
let guard = ProcessGuard::new(12345, "magellan");
guard.terminate()?;Sourcepub fn pid(&self) -> u32
pub fn pid(&self) -> u32
Returns the process ID being guarded.
§Example
use forge_agent::workflow::tools::ProcessGuard;
let guard = ProcessGuard::new(12345, "magellan");
assert_eq!(guard.pid(), 12345);Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns true if the process was terminated.
§Example
use forge_agent::workflow::tools::ProcessGuard;
let guard = ProcessGuard::new(12345, "magellan");
assert!(!guard.is_terminated());Trait Implementations§
Source§impl Clone for ProcessGuard
impl Clone for ProcessGuard
Source§fn clone(&self) -> ProcessGuard
fn clone(&self) -> ProcessGuard
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 moreSource§impl Debug for ProcessGuard
impl Debug for ProcessGuard
Source§impl Display for ProcessGuard
impl Display for ProcessGuard
Source§impl Drop for ProcessGuard
impl Drop for ProcessGuard
Source§impl From<ProcessGuard> for ToolCompensation
impl From<ProcessGuard> for ToolCompensation
Source§fn from(guard: ProcessGuard) -> Self
fn from(guard: ProcessGuard) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ProcessGuard
impl RefUnwindSafe for ProcessGuard
impl Send for ProcessGuard
impl Sync for ProcessGuard
impl Unpin for ProcessGuard
impl UnsafeUnpin for ProcessGuard
impl UnwindSafe for ProcessGuard
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more