pub trait Platform {
type Pid;
type FileDesc;
type TermSettings;
Show 25 methods
// Required methods
fn get_term_settings(terminal: FileDesc) -> Result<TermSettings, Error>;
fn restore_terminal(
term_settings: &TermSettings,
shell_pid: Pid,
) -> Result<(), Error>;
fn terminal_foreground(terminal: FileDesc);
fn set_self_pgroup() -> Result<(), Error>;
fn grab_terminal(terminal: FileDesc) -> Result<(), Error>;
fn anon_pipe() -> Result<(FileDesc, FileDesc), Error>;
fn close_fd(fd: FileDesc) -> Result<(), Error>;
fn fork_run(run: &Run, job: &mut Job, jobs: &mut Jobs) -> Result<(), Error>;
fn fork_exec(
command: &CommandWithArgs,
job: &mut Job,
jobs: &mut Jobs,
) -> Result<(), Error>;
fn try_wait_pid(pid: Pid, job: &mut Job) -> (bool, Option<i32>);
fn wait_job(job: &mut Job) -> Option<i32>;
fn foreground_job(
job: &mut Job,
term_settings: &Option<TermSettings>,
) -> Result<(), Error>;
fn background_job(job: &mut Job) -> Result<(), Error>;
fn dup2_fd(src_fd: FileDesc, dst_fd: FileDesc) -> Result<FileDesc, Error>;
fn getpid() -> Pid;
fn gethostname() -> Option<OsString>;
fn current_uid() -> u32;
fn effective_uid() -> u32;
fn is_tty(terminal: FileDesc) -> bool;
fn set_rlimit(rlimit: RLimit, values: RLimitVals) -> Result<(), Error>;
fn get_rlimit(rlimit: RLimit) -> Result<RLimitVals, Error>;
fn merge_and_set_umask(
current_umask: mode_t,
mask_string: &str,
) -> Result<mode_t, Error>;
fn get_and_clear_umask() -> mode_t;
fn set_umask(umask: mode_t) -> Result<(), Error>;
// Provided method
fn to_octal_string(mode: mode_t) -> Result<String, Error> { ... }
}
Expand description
Abstraction for a “platform” (for instance Unix or Windows).
Required Associated Types§
Required Methods§
Sourcefn get_term_settings(terminal: FileDesc) -> Result<TermSettings, Error>
fn get_term_settings(terminal: FileDesc) -> Result<TermSettings, Error>
If terminal is a terminal then get it’s term settings.
Sourcefn restore_terminal(
term_settings: &TermSettings,
shell_pid: Pid,
) -> Result<(), Error>
fn restore_terminal( term_settings: &TermSettings, shell_pid: Pid, ) -> Result<(), Error>
Restore terminal settings and put the shell back into the foreground.
Sourcefn terminal_foreground(terminal: FileDesc)
fn terminal_foreground(terminal: FileDesc)
Put terminal in the foreground, loop until this succeeds. Used during shell startup.
Sourcefn set_self_pgroup() -> Result<(), Error>
fn set_self_pgroup() -> Result<(), Error>
Puts the running process into its own process group. Do this during shell initialization.
Sourcefn grab_terminal(terminal: FileDesc) -> Result<(), Error>
fn grab_terminal(terminal: FileDesc) -> Result<(), Error>
Grab control of terminal. Used for shell startup.
Sourcefn anon_pipe() -> Result<(FileDesc, FileDesc), Error>
fn anon_pipe() -> Result<(FileDesc, FileDesc), Error>
Return the input and output file descriptors for an anonymous pipe.
fn fork_run(run: &Run, job: &mut Job, jobs: &mut Jobs) -> Result<(), Error>
fn fork_exec( command: &CommandWithArgs, job: &mut Job, jobs: &mut Jobs, ) -> Result<(), Error>
fn try_wait_pid(pid: Pid, job: &mut Job) -> (bool, Option<i32>)
fn wait_job(job: &mut Job) -> Option<i32>
Sourcefn foreground_job(
job: &mut Job,
term_settings: &Option<TermSettings>,
) -> Result<(), Error>
fn foreground_job( job: &mut Job, term_settings: &Option<TermSettings>, ) -> Result<(), Error>
Move the job for job_num to te foreground.
Sourcefn background_job(job: &mut Job) -> Result<(), Error>
fn background_job(job: &mut Job) -> Result<(), Error>
Move the job for job_num to te background and running (start a stopped job in the background).
Sourcefn dup2_fd(src_fd: FileDesc, dst_fd: FileDesc) -> Result<FileDesc, Error>
fn dup2_fd(src_fd: FileDesc, dst_fd: FileDesc) -> Result<FileDesc, Error>
Duplicate a raw file descriptor to another file descriptor.
Sourcefn gethostname() -> Option<OsString>
fn gethostname() -> Option<OsString>
Get the current machines hostname if available.
Sourcefn current_uid() -> u32
fn current_uid() -> u32
Get current UID of the process.
Sourcefn effective_uid() -> u32
fn effective_uid() -> u32
Get effective UID of the process.
fn is_tty(terminal: FileDesc) -> bool
fn set_rlimit(rlimit: RLimit, values: RLimitVals) -> Result<(), Error>
fn get_rlimit(rlimit: RLimit) -> Result<RLimitVals, Error>
Sourcefn merge_and_set_umask(
current_umask: mode_t,
mask_string: &str,
) -> Result<mode_t, Error>
fn merge_and_set_umask( current_umask: mode_t, mask_string: &str, ) -> Result<mode_t, Error>
If mask_string is a mode string then merge it with umask and set the current umask. If mask_string is an int then treat it as a umask and set the current umask (no merge)).
Sourcefn get_and_clear_umask() -> mode_t
fn get_and_clear_umask() -> mode_t
Clears the current umask and returns the previous umask.
Provided Methods§
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.