Struct Monitor

Source
pub struct Monitor { /* private fields */ }
Expand description

Represents a display monitor.

§Examples

let mut monitors = Monitor::enumerate();
monitors[0].set_input_source(InputSource::UsbC1.as_raw());

Implementations§

Source§

impl Monitor

Source

pub fn new(ddc_hi_display: Display) -> Self

Create an instance from ddc_hi::Display.

Source

pub fn enumerate() -> Vec<Self>

Enumerate all display monitors. See also ddc_hi::Display::enumerate().

Source

pub fn set_dry_run(value: bool)

Set the dry-run mode. When in dry-run mode, functions that are supposed to make changes don’t actually make the changes.

Source

pub fn update_capabilities(&mut self) -> Result<()>

Updates the display info with data retrieved from the device’s reported capabilities. See also ddc_hi::Display::update_capabilities().

Source

pub fn input_source(&mut self) -> Result<InputSourceRaw>

Get the current input source.

§Examples
print!("{}", InputSource::str_from_raw(monitor.input_source()?));
Source

pub fn set_input_source(&mut self, value: InputSourceRaw) -> Result<()>

Set the current input source.

§Examples
fn set_to_usbc1(monitor: &mut Monitor) -> anyhow::Result<()> {
  monitor.set_input_source(InputSource::UsbC1.as_raw())
}
fn set_to(monitor: &mut Monitor, input_source_str: &str) -> anyhow::Result<()> {
  monitor.set_input_source(InputSource::raw_from_str(input_source_str)?)
}
Source

pub fn input_sources(&mut self) -> Option<Vec<InputSourceRaw>>

Get all input sources. Requires to call Monitor::update_capabilities() beforehand.

Source

pub fn sleep_if_needed(&mut self)

Sleep if any previous DDC commands need time to be executed. See also ddc_hi::DdcHost::sleep().

Source

pub fn to_long_string(&mut self) -> String

Get a multi-line descriptive string.

Trait Implementations§

Source§

impl Debug for Monitor

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Monitor

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.