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: mod.rs
    path of file: ./repos/smithay/src/backend/drm/node
    
    the code of the file until where you have to start completion: //! Module for abstractions on drm device nodes

pub(crate) mod constants;

use constants::*;

use std::{
    fmt::{self, Display, Formatter},
    io,
    os::unix::io::AsFd,
    path::{Path, PathBuf},
};

use rustix::fs::{fstat, major, minor, stat, Dev as dev_t, Stat};

/// A node which refers to a DRM device.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DrmNode {
    dev: dev_t,
    ty: NodeType,
}

impl DrmNode {
    /// Creates a DRM node from an open drm device.
    ///
    /// This function does not take ownership of the passed in file descriptor.
    pub fn from_file<A: AsFd>(file: A) -> Result<DrmNode, CreateDrmNodeError> {
        let stat = fstat(file).map_err(Into::<io::Error>::into)?;
        DrmNode::from_stat(stat)
    }

    /// Creates a DRM node from path.
    pub fn from_path<A: AsRef<Path>>(path: A) -> Result<DrmNode
    
pub fn dev_path(dev: dev_t, ty: NodeType) -> io::Result<PathBuf> {
    use std::fs;
    use std::io::ErrorKind;

    if !is_device_drm(dev) {
        return Err(io::Error::new(
            ErrorKind::NotFound,
            format!("{}:{} is no DRM device", major(dev), minor(dev)),
        ));
    }

    let read = fs::read_dir(format!("/sys/dev/char/{}:{}/device/drm", major(dev), minor(dev)))?;

    for entry in read.flatten() {
        let name = entry.file_name();
        let name = name.to_string_lossy();

        // Only 1 primary, control and render node may exist simultaneously, so the
        // first occurrence is good enough.
        if name.starts_with(ty.minor_name_prefix()) {
            let path = [r"/", "dev", "dri", &name].iter().collect::<PathBuf>();
            if path.exists() {
                return Ok(path);
            }
        }
    }

    Err(io::Error::new(
        ErrorKind::NotFound,
        format!(
            "Could not find node of type {} from DRM device {}:{}",
            ty,
            major(dev),
            minor(dev)
        ),
    ))
}