pub struct Monitor { /* private fields */ }Expand description
Represents a display monitor.
§Example
use windows_capture::monitor::Monitor;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let monitor = Monitor::primary()?;
println!("Primary Monitor: {}", monitor.name()?);
Ok(())
}Implementations§
Source§impl Monitor
impl Monitor
Sourcepub fn primary() -> Result<Self, Error>
pub fn primary() -> Result<Self, Error>
Returns the primary monitor.
§Errors
Returns Error::NotFound if the primary monitor cannot be found.
Sourcepub fn from_index(index: usize) -> Result<Self, Error>
pub fn from_index(index: usize) -> Result<Self, Error>
Sourcepub fn index(&self) -> Result<usize, Error>
pub fn index(&self) -> Result<usize, Error>
Returns the one-based index of the monitor.
§Errors
Returns an Error if the monitor’s device name cannot be parsed to determine the index.
Sourcepub fn name(&self) -> Result<String, Error>
pub fn name(&self) -> Result<String, Error>
Returns the friendly name of the monitor.
§Errors
Returns an Error if the monitor’s name cannot be retrieved.
Sourcepub fn device_name(&self) -> Result<String, Error>
pub fn device_name(&self) -> Result<String, Error>
Returns the device name of the monitor (e.g., \\.\DISPLAY1).
§Errors
Returns an Error if the monitor’s device name cannot be retrieved.
Sourcepub fn device_string(&self) -> Result<String, Error>
pub fn device_string(&self) -> Result<String, Error>
Returns the device string of the monitor (e.g., NVIDIA GeForce RTX 4090).
§Errors
Returns an Error if the monitor’s device string cannot be retrieved.
Sourcepub fn refresh_rate(&self) -> Result<u32, Error>
pub fn refresh_rate(&self) -> Result<u32, Error>
Returns the refresh rate of the monitor in hertz (Hz).
§Errors
Returns an Error if the monitor’s refresh rate cannot be retrieved.
Sourcepub fn width(&self) -> Result<u32, Error>
pub fn width(&self) -> Result<u32, Error>
Returns the width of the monitor in pixels.
§Errors
Returns an Error if the monitor’s width cannot be retrieved.
Sourcepub fn height(&self) -> Result<u32, Error>
pub fn height(&self) -> Result<u32, Error>
Returns the height of the monitor in pixels.
§Errors
Returns an Error if the monitor’s height cannot be retrieved.
Sourcepub fn enumerate() -> Result<Vec<Self>, Error>
pub fn enumerate() -> Result<Vec<Self>, Error>
Returns a list of all available monitors.
§Errors
Returns an Error if the monitor enumeration fails.
Sourcepub const fn from_raw_hmonitor(monitor: *mut c_void) -> Self
pub const fn from_raw_hmonitor(monitor: *mut c_void) -> Self
Creates a Monitor instance from a raw HMONITOR handle.
§Arguments
hmonitor- The rawHMONITORhandle.
Sourcepub const fn as_raw_hmonitor(&self) -> *mut c_void
pub const fn as_raw_hmonitor(&self) -> *mut c_void
Returns the raw HMONITOR handle of the monitor.
Trait Implementations§
Source§impl TryIntoCaptureItemWithType for Monitor
impl TryIntoCaptureItemWithType for Monitor
Source§fn try_into_capture_item(
self,
) -> Result<(GraphicsCaptureItem, CaptureItemTypes), Error>
fn try_into_capture_item( self, ) -> Result<(GraphicsCaptureItem, CaptureItemTypes), Error>
GraphicsCaptureItem and its corresponding CaptureItemTypes variant.impl Copy for Monitor
impl Eq for Monitor
impl Send for Monitor
impl StructuralPartialEq for Monitor
Auto Trait Implementations§
impl Freeze for Monitor
impl RefUnwindSafe for Monitor
impl !Sync for Monitor
impl Unpin for Monitor
impl UnwindSafe for Monitor
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more