40 lines
785 B
Rust
40 lines
785 B
Rust
//! Job scheduling.
|
|
|
|
use super::Result;
|
|
|
|
use std::marker::PhantomData;
|
|
|
|
use sealed::Sealed;
|
|
mod sealed {
|
|
pub trait Sealed {}
|
|
}
|
|
|
|
/// An empty type used to tag a [`Job`] as running in the background.
|
|
pub enum Stopped {}
|
|
impl Sealed for Stopped {}
|
|
|
|
/// An empty type used to tag a [`Job`] as running in the foreground.
|
|
pub enum Running {}
|
|
impl Sealed for Running {}
|
|
|
|
/// Represents a running process, either in the foreground
|
|
/// or in the background.
|
|
pub struct Job <State: Sealed> {
|
|
_t: PhantomData<State>,
|
|
}
|
|
|
|
impl Job<Running> {
|
|
|
|
/// Attempt to send this job to the background.
|
|
pub fn bg (self) -> Result<Job<Stopped>> { todo!() }
|
|
|
|
}
|
|
|
|
impl Job<Stopped> {
|
|
|
|
/// Attempt to pull this job to the foreground.
|
|
pub fn fg (self) -> Result<Job<Running>> { todo!() }
|
|
|
|
}
|
|
|