pub fn from_fd<A: AsRawFd>(fd: A) -> Result<DrmNode, CreateDrmNodeError> {
        let fd = fd.as_raw_fd();
        let stat = fstat(fd).map_err(Into::<io::Error>::into)?;
        let dev = stat.st_rdev;
        let major = major(dev);
        let minor = minor(dev);

        if !is_device_drm(major, minor) {
            return Err(CreateDrmNodeError::NotDrmNode);
        }

        /*
        The type of the DRM node is determined by the minor number ranges.

        0-63 -> Primary
        64-127 -> Control
        128-255 -> Render
        */
        let ty = match minor >> 6 {
            0 => NodeType::Primary,
            1 => NodeType::Control,
            2 => NodeType::Render,
            _ => return Err(CreateDrmNodeError::NotDrmNode),
        };

        Ok(DrmNode { fd, dev, ty })
    }
/// Creates a DRM node from a file descriptor.
///
/// This function takes ownership of the passed in file descriptor, which will be closed when
/// dropped.
Creates a DRM node from a file descriptor.
This function takes ownership of the passed in file descriptor, which will be closed when
dropped.
Creates a DRM node from a file descriptor . This function takes ownership of the passed in file descriptor which will be closed when dropped .
pub fn from_fd<A: AsRawFd>(fd: A) -> Result<DrmNode, CreateDrmNodeError> {
        let fd = fd.as_raw_fd();
        let stat = fstat(fd).map_err(Into::<io::Error>::into)?;
        let dev = stat.st_rdev;
        let major = major(dev);
        let minor = minor(dev);
        if !is_device_drm(major, minor) {
            return Err(CreateDrmNodeError::NotDrmNode);
        }
        /*
        The type of the DRM node is determined by the minor number ranges.
        0-63 -> Primary
        64-127 -> Control
        128-255 -> Render
        */
        let ty = match minor >> 6 {
            0 => NodeType::Primary,
            1 => NodeType::Control,
            2 => NodeType::Render,
            _ => return Err(CreateDrmNodeError::NotDrmNode),
        };
        Ok(DrmNode { fd, dev, ty })
    }
pub fn from_fd < A : AsRawFd > ( fd : A ) -> Result < DrmNode , CreateDrmNodeError > { let fd = fd . as_raw_fd ( ) ; let stat = fstat ( fd ) . map_err ( Into :: < io :: Error > :: into ) ? ; let dev = stat . st_rdev ; let major = major ( dev ) ; let minor = minor ( dev ) ; if ! is_device_drm ( major , minor ) { return Err ( CreateDrmNodeError :: NotDrmNode ) ; } /*
        The type of the DRM node is determined by the minor number ranges.

        0-63 -> Primary
        64-127 -> Control
        128-255 -> Render
        */ let ty = match minor >> 6 { 0 => NodeType :: Primary , 1 => NodeType :: Control , 2 => NodeType :: Render , _ => return Err ( CreateDrmNodeError :: NotDrmNode ) , } ; Ok ( DrmNode { fd , dev , ty } ) }
Creates a DRM node from a file descriptor.
Creates a DRM node from a file descriptor .
fd
A
fd
A