xrandr_parser

Struct Parser

Source
pub struct Parser {
    pub outputs: Vec<String>,
    pub connected_outputs: Vec<String>,
    pub connectors: Vec<Connector>,
    pub screen: Screen,
}

Fields§

§outputs: Vec<String>

Every Connector.name

§connected_outputs: Vec<String>

Every Connector.name where Connector.status is true

§connectors: Vec<Connector>

Every Connector Struct

§screen: Screen

The Virtual Screen

Implementations§

Source§

impl Parser

Source

pub fn new() -> Parser

Create a new instance of Parser

Source

pub fn parse(&mut self) -> Result<(), String>

Populate properties of an instance of Parser from the output of Parser::parse_query()

Source

pub fn outputs(&self) -> Vec<String>

Getter function for Parser.outputs

§Example
 #[allow(non_snake_case)]

 use xrandr_parser::Parser;

 fn main() -> Result<(), String> {
     let mut XrandrParser = Parser::new();

     XrandrParser.parse()?;

     let outputs = &XrandrParser.outputs();

     Ok(())
 }
Source

pub fn connected_outputs(&self) -> Vec<String>

Getter function for Parser.connected_outputs

§Example
#[allow(non_snake_case)]

use xrandr_parser::Parser;

fn main() -> Result<(), String> {
    let mut XrandrParser = Parser::new();

    XrandrParser.parse()?;

    let connected_outputs = &XrandrParser.connected_outputs();

    println!("Connected Outputs: {:?}", connected_outputs);

    Ok(())
}
Source

pub fn connectors(&self) -> Vec<Connector>

Getter function for Parser.connectors

§Example
 #[allow(non_snake_case)]

 use xrandr_parser::Parser;

 fn main() -> Result<(), String> {
     let mut XrandrParser = Parser::new();

     XrandrParser.parse()?;

     let connectors = &XrandrParser.connectors();

     println!("Connectors: {:#?}", connectors);

     Ok(())
}
Source

pub fn screen(&self) -> Screen

Getter function for Parser.screen

§Example
#[allow(non_snake_case)]

use xrandr_parser::Parser;

fn main() -> Result<(), String> {
    let mut XrandrParser = Parser::new();

    XrandrParser.parse()?;

    let screen = &XrandrParser.screen();

    println!("Screen Information: {:#?}", screen);

    Ok(())
}
Source

pub fn get_connector(&self, connector: &str) -> Result<Connector, String>

Get the connector struct for a with the name provided. Returns "Not found" if the connector is not found in self.connectors.

§Example
#[allow(non_snake_case)]

use xrandr_parser::Parser;

fn main() -> Result<(), String> {
    let mut XrandrParser = Parser::new();

    XrandrParser.parse()?;

    let connector = &XrandrParser.get_connector("HDMI-1")?;

    println!("Connector - HDMI-1: {:#?}", connector);

    Ok(())
}

Trait Implementations§

Source§

impl Debug for Parser

Source§

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

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

impl Default for Parser

Source§

fn default() -> Parser

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Parser

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Parser

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Parser

§

impl RefUnwindSafe for Parser

§

impl Send for Parser

§

impl Sync for Parser

§

impl Unpin for Parser

§

impl UnwindSafe for Parser

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,