pub struct Job {
pub id: JobId,
pub command: String,
/* private fields */
}Expand description
A background job.
Fields§
§id: JobIdJob ID.
command: StringCommand description.
Implementations§
Source§impl Job
impl Job
Sourcepub fn new(
id: JobId,
session_id: u64,
command: String,
handle: JoinHandle<ExecResult>,
) -> Self
pub fn new( id: JobId, session_id: u64, command: String, handle: JoinHandle<ExecResult>, ) -> Self
Create a new job from a task handle.
Sourcepub fn from_channel(
id: JobId,
session_id: u64,
command: String,
rx: Receiver<ExecResult>,
) -> Self
pub fn from_channel( id: JobId, session_id: u64, command: String, rx: Receiver<ExecResult>, ) -> Self
Create a new job from a result channel.
Sourcepub fn with_streams(
id: JobId,
session_id: u64,
command: String,
rx: Receiver<ExecResult>,
stdout: Arc<BoundedStream>,
stderr: Arc<BoundedStream>,
) -> Self
pub fn with_streams( id: JobId, session_id: u64, command: String, rx: Receiver<ExecResult>, stdout: Arc<BoundedStream>, stderr: Arc<BoundedStream>, ) -> Self
Create a new job with attached output streams.
The streams provide live access to job output via /v/jobs/{id}/stdout and /stderr.
Sourcepub fn stopped(
id: JobId,
session_id: u64,
command: String,
pid: u32,
pgid: u32,
) -> Self
pub fn stopped( id: JobId, session_id: u64, command: String, pid: u32, pgid: u32, ) -> Self
Create a stopped job (from Ctrl-Z on a foreground process).
Sourcepub fn output_file(&self) -> Option<&PathBuf>
pub fn output_file(&self) -> Option<&PathBuf>
Get the output file path (if available).
Sourcepub fn is_done(&mut self) -> bool
pub fn is_done(&mut self) -> bool
Check if the job has completed.
Stopped jobs are not considered done.
Sourcepub fn status_string(&mut self) -> String
pub fn status_string(&mut self) -> String
Get the job’s status as a string suitable for /v/jobs/{id}/status.
Returns:
"running"if the job is still running"done:0"if the job completed successfully"failed:{code}"if the job failed with an exit code
Sourcepub fn stdout_stream(&self) -> Option<&Arc<BoundedStream>>
pub fn stdout_stream(&self) -> Option<&Arc<BoundedStream>>
Get the stdout stream (if attached).
Sourcepub fn stderr_stream(&self) -> Option<&Arc<BoundedStream>>
pub fn stderr_stream(&self) -> Option<&Arc<BoundedStream>>
Get the stderr stream (if attached).
Sourcepub fn cleanup_files(&mut self)
pub fn cleanup_files(&mut self)
Remove any temp files associated with this job.
Sourcepub fn try_result(&self) -> Option<&ExecResult>
pub fn try_result(&self) -> Option<&ExecResult>
Get the result if completed, without waiting.
Auto Trait Implementations§
impl !RefUnwindSafe for Job
impl !UnwindSafe for Job
impl Freeze for Job
impl Send for Job
impl Sync for Job
impl Unpin for Job
impl UnsafeUnpin for Job
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