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 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 streams(&self) -> JobStreams
pub fn streams(&self) -> JobStreams
This job’s live output streams (see JobStreams).
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"stopped"if the job is stopped (Ctrl-Z / SIGTSTP)"done:0"if the job completed successfully"killed:{code}"if the job was terminated bykill %N"failed:{code}"if the job failed with an exit code
The vocabulary must stay in step with Self::status — GH #252 was
exactly this pair drifting: status() learned the stopped check and
this string twin didn’t, so /v/jobs/N/status reported a Ctrl-Z’d job
as "running" forever (a stopped job has no result channel, so
try_poll can never produce a result).
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> Pointable for T
impl<T> Pointable for T
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.