shell::platform

Trait Platform

Source
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§

Source

fn get_term_settings(terminal: FileDesc) -> Result<TermSettings, Error>

If terminal is a terminal then get it’s term settings.

Source

fn restore_terminal( term_settings: &TermSettings, shell_pid: Pid, ) -> Result<(), Error>

Restore terminal settings and put the shell back into the foreground.

Source

fn terminal_foreground(terminal: FileDesc)

Put terminal in the foreground, loop until this succeeds. Used during shell startup.

Source

fn set_self_pgroup() -> Result<(), Error>

Puts the running process into its own process group. Do this during shell initialization.

Source

fn grab_terminal(terminal: FileDesc) -> Result<(), Error>

Grab control of terminal. Used for shell startup.

Source

fn anon_pipe() -> Result<(FileDesc, FileDesc), Error>

Return the input and output file descriptors for an anonymous pipe.

Source

fn close_fd(fd: FileDesc) -> Result<(), Error>

Close a raw file descriptor.

Source

fn fork_run(run: &Run, job: &mut Job, jobs: &mut Jobs) -> Result<(), Error>

Source

fn fork_exec( command: &CommandWithArgs, job: &mut Job, jobs: &mut Jobs, ) -> Result<(), Error>

Source

fn try_wait_pid(pid: Pid, job: &mut Job) -> (bool, Option<i32>)

Source

fn wait_job(job: &mut Job) -> Option<i32>

Source

fn foreground_job( job: &mut Job, term_settings: &Option<TermSettings>, ) -> Result<(), Error>

Move the job for job_num to te foreground.

Source

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).

Source

fn dup2_fd(src_fd: FileDesc, dst_fd: FileDesc) -> Result<FileDesc, Error>

Duplicate a raw file descriptor to another file descriptor.

Source

fn getpid() -> Pid

Get the current PID.

Source

fn gethostname() -> Option<OsString>

Get the current machines hostname if available.

Source

fn current_uid() -> u32

Get current UID of the process.

Source

fn effective_uid() -> u32

Get effective UID of the process.

Source

fn is_tty(terminal: FileDesc) -> bool

Source

fn set_rlimit(rlimit: RLimit, values: RLimitVals) -> Result<(), Error>

Source

fn get_rlimit(rlimit: RLimit) -> Result<RLimitVals, Error>

Source

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)).

Source

fn get_and_clear_umask() -> mode_t

Clears the current umask and returns the previous umask.

Source

fn set_umask(umask: mode_t) -> Result<(), Error>

Set current umask to umask.

Provided Methods§

Source

fn to_octal_string(mode: mode_t) -> Result<String, Error>

Convert mode to the octal string umask format.

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.

Implementors§