diff --git a/src/main.rs b/src/main.rs index 47e021a..e7b555d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,26 +11,32 @@ fn main() { }; println!("{:?}", gpu); + print_connectors(&gpu); +} +fn print_connectors(gpu: &card::Card) { let resource_handles = gpu.resource_handles().unwrap(); println!("Connectors:"); for handle in resource_handles.connectors() { - match gpu.get_connector(*handle, false) { - Ok(connector) => { - println!("\t{} ({:?})", connector.interface().as_str(), connector.state()); - - let encoder_info = format_encoder(&gpu, connector.current_encoder()); - - println!("\t\tEncoder: {}", encoder_info); - - println!(""); // Add blank line - }, - Err(_) => {} - } + print_connector(&gpu, handle); } } +fn print_connector(gpu: &card::Card, connector_handle: &drm::control::connector::Handle) { + match gpu.get_connector(*connector_handle, false) { + Ok(connector) => { + println!("\t{} ({:?})", connector.interface().as_str(), connector.state()); + + let encoder_info = format_encoder(&gpu, connector.current_encoder()); + + println!("\t\tEncoder: {}", encoder_info); + println!(""); // Add blank line + }, + Err(_) => {} + }; +} + fn format_encoder(gpu: &card::Card, encoder_handle: Option) -> String { match encoder_handle.and_then(|handle| gpu.get_encoder(handle).ok()) { Some(encoder) => {