use std::fmt;

use super::{Content, Dir, Query, VPath};

pub struct BufferedFile {
    pub content: Content,
}

impl BufferedFile {
    pub fn new(content: Content) -> Self {
        Self { content }
    }
}

impl Dir for BufferedFile {
    fn query(&self, path: &VPath, query: &mut Query) {
        if path == VPath::ROOT {
            query.provide(|| self.content.clone());
        }
    }
}

impl fmt::Debug for BufferedFile {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "BufferedFile")
    }
}
