You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: dxgi.rs
    path of file: ./repos/rustdesk/libs/scrap/src/common
    
    the code of the file until where you have to start completion: #[cfg(feature = "gpucodec")]
use crate::AdapterDevice;
use crate::{common::TraitCapturer, dxgi, Frame, Pixfmt};
use std::{
    io::{
        self,
        ErrorKind::{NotFound, TimedOut, WouldBlock},
    },
    time::Duration,
};

pub struct Capturer {
    inner: dxgi::Capturer,
    width: usize,
    height: usize,
}

impl Capturer {
    pub fn new(display: Display) -> io::Result<Capturer> {
        let width = display.width();
        let height = display.height();
        let inner = dxgi::Capturer::new(display.0)?;
        Ok(Capturer {
            inner,
            width,
            height,
        })
    }

    pub fn cancel_gdi(&mut self) {
        self.inner.cancel_gdi()
    }

    pub fn width(&self) -> usize {
        self.width
    }

    pub fn height(&self) -> usize {
        self.height
    }
}

impl TraitCapturer for Capturer {
    fn frame<'a>(&'a mut self, timeout: Duration) -> io::Result<Frame<'a>> {
        match self.inner.frame(timeout.as_millis() as _) {
            Ok(frame) => Ok(frame),
            Err(ref error) if error.kind() == TimedOut => Err(WouldBlock.into()),
            Err(error) => Err
    
    pub fn all() -> io::Result<Vec<Display>> {
        let displays_gdi = dxgi::Displays::get_from_gdi()
            .drain(..)
            .map(Display)
            .collect::<Vec<_>>();

        let displays_dxgi = Self::all_().unwrap_or(Default::default());

        // Return gdi displays if dxgi is not supported
        if displays_dxgi.is_empty() {
            println!("Display got from gdi");
            return Ok(displays_gdi);
        }

        // Return dxgi displays if length is not equal
        if displays_dxgi.len() != displays_gdi.len() {
            return Ok(displays_dxgi);
        }

        // Check if names are equal
        let names_gdi = displays_gdi.iter().map(|d| d.name()).collect::<Vec<_>>();
        let names_dxgi = displays_dxgi.iter().map(|d| d.name()).collect::<Vec<_>>();
        for name in names_gdi.iter() {
            if !names_dxgi.contains(name) {
                return Ok(displays_dxgi);
            }
        }

        // Reorder displays from dxgi
        let mut displays_dxgi = displays_dxgi;
        let mut displays_dxgi_ordered = Vec::new();
        for name in names_gdi.iter() {
            let pos = match displays_dxgi.iter().position(|d| d.name() == *name) {
                Some(pos) => pos,
                None => {
                    // unreachable!
                    0
                }
            };
            displays_dxgi_ordered.push(displays_dxgi.remove(pos));
        }

        Ok(displays_dxgi_ordered)
    }