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: app.rs
    path of file: ./repos/viu/src
    
    the code of the file until where you have to start completion: use crate::config::Config;
use crossterm::terminal::{Clear, ClearType};
use crossterm::{cursor, execute};
use image::{codecs::gif::GifDecoder, AnimationDecoder, DynamicImage};
use std::fs;
use std::io::{stdin, stdout, BufReader, Error, ErrorKind, Read, Seek};
use std::sync::mpsc;
use std::{thread, time::Duration};
use viuer::ViuResult;

type TxRx<'a> = (&'a mpsc::Sender<bool>, &'a mpsc::Receiver<bool>);

// TODO: Create a viu-specific result and error types, do not reuse viuer's
pub fn run(mut conf: Config) -> ViuResult {
    //create two channels so that ctrlc-handler and the main thread can pass messages in order to
    // communicate when printing must be stopped without distorting the current frame
    let (tx_ctrlc, rx_print) = mpsc::channel();
    let (tx_print, rx_ctrlc) = mpsc::channel();

    //handle Ctrl-C in order to clean up after ourselves
    ctrlc::set_handler(move || {
      
    
fn view_directory(conf: &Config, dirname: &str, (tx, rx): TxRx) -> ViuResult {
    for dir_entry_result in fs::read_dir(dirname)? {
        //check if Ctrl-C has been received. If yes, stop iterating
        if rx.try_recv().is_ok() {
            return tx.send(true).map_err(|_| {
                Error::new(ErrorKind::Other, "Could not send signal to clean up.").into()
            });
        };
        let dir_entry = dir_entry_result?;

        //check if the given file is a directory
        if let Some(path_name) = dir_entry.path().to_str() {
            //if -r is passed, continue down
            if conf.recursive && dir_entry.metadata()?.is_dir() {
                view_directory(conf, path_name, (tx, rx))?;
            }
            //if it is a regular file, viu it, but do not exit on error
            else {
                let _ = view_file(conf, path_name, (tx, rx));
            }
        } else {
            eprintln!("Could not get path name, skipping...");
            continue;
        }
    }

    Ok(())
}