[thin_shrink] Add NoopVisitor
This commit is contained in:
		@@ -26,7 +26,6 @@ fn main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // FIXME: check these look like xml
 | 
					    // FIXME: check these look like xml
 | 
				
			||||||
    let input_file = matches.value_of("INPUT").unwrap();
 | 
					    let input_file = matches.value_of("INPUT").unwrap();
 | 
				
			||||||
    let map_file = matches.value_of("MAP").unwrap();
 | 
					 | 
				
			||||||
    let output_file = matches.value_of("OUTPUT").unwrap();
 | 
					    let output_file = matches.value_of("OUTPUT").unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if !file_utils::file_exists(input_file) {
 | 
					    if !file_utils::file_exists(input_file) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,14 +6,15 @@ use crate::shrink::xml;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
//---------------------------------------
 | 
					//---------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn shrink(input_file: &str, _output_file: &str, _map_file: &str) -> Result<()> {
 | 
					pub fn shrink(input_file: &str, _output_file: &str) -> Result<()> {
 | 
				
			||||||
    let input = OpenOptions::new()
 | 
					    let input = OpenOptions::new()
 | 
				
			||||||
        .read(true)
 | 
					        .read(true)
 | 
				
			||||||
        .write(false)
 | 
					        .write(false)
 | 
				
			||||||
        .custom_flags(libc::O_EXCL)
 | 
					        .custom_flags(libc::O_EXCL)
 | 
				
			||||||
        .open(input_file)?;
 | 
					        .open(input_file)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let mut visitor = xml::XmlWriter::new(std::io::stdout());
 | 
					    // let mut visitor = xml::XmlWriter::new(std::io::stdout());
 | 
				
			||||||
 | 
					    let mut visitor = xml::NoopVisitor::new();
 | 
				
			||||||
    xml::read(input, &mut visitor)?;
 | 
					    xml::read(input, &mut visitor)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(())
 | 
					    Ok(())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,6 +51,25 @@ pub trait MetadataVisitor {
 | 
				
			|||||||
    fn eof(&mut self) -> Result<()>;
 | 
					    fn eof(&mut self) -> Result<()>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub struct NoopVisitor {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl NoopVisitor {
 | 
				
			||||||
 | 
					    pub fn new() -> NoopVisitor { NoopVisitor {} }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl MetadataVisitor for NoopVisitor {
 | 
				
			||||||
 | 
					    fn superblock_b(&mut self, _sb: &Superblock) -> Result<()> {Ok(())}
 | 
				
			||||||
 | 
					    fn superblock_e(&mut self) -> Result<()> {Ok(())}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn device_b(&mut self, _d: &Device) -> Result<()> {Ok(())}
 | 
				
			||||||
 | 
					    fn device_e(&mut self) -> Result<()> {Ok(())}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn map(&mut self, _m: Map) -> Result<()> {Ok(())}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn eof(&mut self) -> Result<()> {Ok(())}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct XmlWriter<W: Write> {
 | 
					pub struct XmlWriter<W: Write> {
 | 
				
			||||||
    w: Writer<W>,
 | 
					    w: Writer<W>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user