Struct display_info::DisplayInfo

source ·
pub struct DisplayInfo {
    pub name: String,
    pub id: u32,
    pub raw_handle: HMONITOR,
    pub x: i32,
    pub y: i32,
    pub width: u32,
    pub height: u32,
    pub rotation: f32,
    pub scale_factor: f32,
    pub frequency: f32,
    pub is_primary: bool,
}

Fields§

§name: String

The Display Name

§id: u32

Unique identifier associated with the display.

§raw_handle: HMONITOR

Native screen raw handle

§x: i32

The display x coordinate.

§y: i32

The display x coordinate.

§width: u32

The display pixel width.

§height: u32

The display pixel height.

§rotation: f32

Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.

§scale_factor: f32

Output device’s pixel scale factor.

§frequency: f32

The display refresh rate.

§is_primary: bool

Whether the screen is the main screen

Implementations§

source§

impl DisplayInfo

source

pub fn all() -> Result<Vec<DisplayInfo>>

Examples found in repository?
examples/display_info.rs (line 7)
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    let start = Instant::now();

    let display_infos = DisplayInfo::all().unwrap();
    for display_info in display_infos {
        println!("display_info {display_info:?}");
    }
    let display_info = DisplayInfo::from_point(100, 100).unwrap();
    println!("display_info {display_info:?}");
    println!("运行耗时: {:?}", start.elapsed());
}
source

pub fn from_point(x: i32, y: i32) -> Result<DisplayInfo>

Examples found in repository?
examples/display_info.rs (line 11)
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    let start = Instant::now();

    let display_infos = DisplayInfo::all().unwrap();
    for display_info in display_infos {
        println!("display_info {display_info:?}");
    }
    let display_info = DisplayInfo::from_point(100, 100).unwrap();
    println!("display_info {display_info:?}");
    println!("运行耗时: {:?}", start.elapsed());
}
source

pub fn from_name(name: impl ToString) -> Result<DisplayInfo>

Trait Implementations§

source§

impl Clone for DisplayInfo

source§

fn clone(&self) -> DisplayInfo

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for DisplayInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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
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.

source§

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

§

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>,

§

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>,

§

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.