Skip to main content

DefaultWindowsApi

Struct DefaultWindowsApi 

pub struct DefaultWindowsApi;
Expand description

Default implementation of WindowsApi that calls actual Windows APIs.

This implementation provides direct access to Windows system APIs and should be used in production code. For testing, use the MockWindowsApi instead.

Trait Implementations§

Source§

impl Clone for DefaultWindowsApi

Source§

fn clone(&self) -> DefaultWindowsApi

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl WindowsApi for DefaultWindowsApi

Source§

fn set_console_title(&self, title: &str) -> Result<(), Error>

Sets the console window title. Read more
Source§

fn get_console_title(&self, buffer: &mut [u16]) -> i32

Gets the console window title as UTF-16 buffer. Read more
Source§

fn get_os_version(&self) -> String

Gets OS version string. Read more
Source§

fn arrange_console( &self, x: i32, y: i32, width: i32, height: i32, ) -> Result<(), Error>

Arranges the console window position and size. Read more
Source§

fn set_console_text_attribute( &self, attributes: CONSOLE_CHARACTER_ATTRIBUTES, ) -> Result<(), Error>

Sets console text attribute. Read more
Source§

fn get_console_screen_buffer_info( &self, ) -> Result<CONSOLE_SCREEN_BUFFER_INFO, Error>

Gets console screen buffer info. Read more
Source§

fn fill_console_output_attribute( &self, attribute: u16, length: u32, coord: COORD, ) -> Result<u32, Error>

Fills console output with specified attribute. Read more
Source§

fn read_console_output_attribute( &self, length: u32, coord: COORD, ) -> Result<Vec<u16>, Error>

Reads a run of per-cell attributes from the console screen buffer. Read more
Source§

fn write_console_output_attribute( &self, attributes: &[u16], coord: COORD, ) -> Result<u32, Error>

Writes a run of per-cell attributes to the console screen buffer. Read more
Source§

fn get_console_screen_buffer_info_ex( &self, ) -> Result<CONSOLE_SCREEN_BUFFER_INFOEX, Error>

Reads the extended console screen buffer info, including the 16-entry RGB color palette. Read more
Source§

fn set_console_screen_buffer_info_ex( &self, info: &CONSOLE_SCREEN_BUFFER_INFOEX, ) -> Result<(), Error>

Writes the extended console screen buffer info, including the 16-entry RGB color palette. Read more
Source§

fn scroll_console_screen_buffer( &self, scroll_rect: SMALL_RECT, scroll_target: COORD, fill_char: CHAR_INFO, ) -> Result<(), Error>

Scrolls console screen buffer. Read more
Source§

fn set_console_cursor_position(&self, position: COORD) -> Result<(), Error>

Sets console cursor position. Read more
Source§

fn get_std_handle(&self, handle_type: STD_HANDLE) -> Result<HANDLE, Error>

Gets standard handle. Read more
Source§

fn read_console_input(&self, buffer: &mut [INPUT_RECORD]) -> Result<u32, Error>

Reads console input. Read more
Source§

fn set_console_border_color(&self, color: &COLORREF) -> Result<(), Error>

Sets DWM window attribute for border color. Read more
Source§

fn invalidate_console_window(&self) -> Result<(), Error>

Marks the entire console window client area as needing a redraw. Read more
Source§

fn write_console_input( &self, buffer: &[INPUT_RECORD], number_written: &mut u32, ) -> Result<(), Error>

Writes input records to the console input buffer. Read more
Source§

fn get_last_error(&self) -> u32

Gets the last Windows error code. Read more
Source§

fn interrupt_console_process_group(&self) -> Result<(), Error>

Interrupt every process attached to the caller’s console. Read more
Source§

fn generate_console_ctrl_event( &self, ctrl_event: u32, process_group_id: u32, ) -> Result<(), Error>

Source§

fn install_console_ctrl_handler(&self) -> Result<(), Error>

Install a console control handler that shields this process from CTRL+C and CTRL+Break. Read more
Source§

fn get_stdout_handle(&self) -> Result<HANDLE, Error>

Get standard output handle Read more
Source§

fn get_console_attached_process_count(&self) -> u32

Get console screen buffer information Read more
Source§

fn get_window_handle_for_process(&self, process_id: u32) -> HWND

Get window handle for process ID Read more
Source§

fn create_process_raw( &self, application: &str, command_line: PWSTR, startup_info: &mut STARTUPINFOW, process_info: &mut PROCESS_INFORMATION, ) -> Result<(), Error>

Low-level process creation API call Read more
Source§

fn create_process_raw_wide( &self, application_wide: &[u16], command_line: PWSTR, startup_info: &mut STARTUPINFOW, process_info: &mut PROCESS_INFORMATION, ) -> Result<(), Error>

Low-level CreateProcessW call accepting an already-wide, null-terminated application path. Read more
Source§

fn get_console_window(&self) -> HWND

Gets the console window handle. Read more
Source§

fn get_foreground_window(&self) -> HWND

Gets the foreground window handle. Read more
Source§

fn bring_window_to_top( &self, hwnd: HWND, with_keyboard_focus: bool, ) -> Result<(), Error>

Bring hwnd to the top of the z-order. Read more
Source§

fn get_console_mode(&self, handle: HANDLE) -> Result<CONSOLE_MODE, Error>

Gets console mode for the specified handle. Read more
Source§

fn set_console_mode( &self, handle: HANDLE, mode: CONSOLE_MODE, ) -> Result<(), Error>

Sets console mode for the specified handle. Read more
Source§

fn get_exit_code(&self, handle: HANDLE) -> Result<u32, Error>

Gets the exit code of the specified process. Read more
Source§

fn move_window( &self, hwnd: HWND, x: i32, y: i32, width: i32, height: i32, repaint: bool, ) -> Result<(), Error>

Moves and resizes a window. Read more
Source§

fn get_window_placement(&self, hwnd: HWND) -> Result<WINDOWPLACEMENT, Error>

Gets window placement information. Read more
Source§

fn show_window( &self, hwnd: HWND, cmd_show: SHOW_WINDOW_CMD, ) -> Result<bool, Error>

Shows a window in the specified state. Read more
Source§

fn is_window(&self, hwnd: HWND) -> bool

Checks if a window handle is valid. Read more
Source§

fn open_process( &self, access: u32, inherit: bool, process_id: u32, ) -> Result<HANDLE, Error>

Opens a process with the specified access rights. Read more
Source§

fn get_system_metrics(&self, index: SYSTEM_METRICS_INDEX) -> i32

Gets system metrics information. Read more
Source§

fn set_process_dpi_awareness( &self, value: PROCESS_DPI_AWARENESS, ) -> Result<(), Error>

Sets the process DPI awareness. Read more
Source§

fn create_process_with_args( &self, application: &str, args: Vec<String>, with_keyboard_focus: bool, ) -> Option<PROCESS_INFORMATION>

Create a new process attached to its own console window. Read more
Source§

fn create_process_with_os_args( &self, application: &OsStr, args: &[OsString], with_keyboard_focus: bool, ) -> Result<PROCESS_INFORMATION, Error>

Create a new process from OsStr/OsString inputs without lossy UTF-8 conversion. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.