use vfile::util::location::Location;

pub trait DirTransport {
    fn can_handle(&self, loc: &Location) -> bool;
    fn is_dir(&self, loc: &Location) -> bool;
    fn read_dir(&self, loc: &Location) -> std::io::Result<Box<dyn Iterator<Item = Location>>>;

    fn box_clone(&self) -> Box<dyn DirTransport>;
    fn name(&self) -> &str;
}

impl Clone for Box<dyn DirTransport> {
    fn clone(&self) -> Box<dyn DirTransport> {
        self.box_clone()
    }
}

impl std::fmt::Debug for dyn DirTransport {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.name())
    }
}
