diff --git a/src/extractors/tarball.rs b/src/extractors/tarball.rs index 96ae07fb..f482b77d 100644 --- a/src/extractors/tarball.rs +++ b/src/extractors/tarball.rs @@ -1,6 +1,27 @@ use crate::extractors; /// Describes how to run the tar utility to extract tarball archives +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::tarball::tarball_extractor; +/// +/// match tarball_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn tarball_extractor() -> extractors::common::Extractor { extractors::common::Extractor { utility: extractors::common::ExtractorType::External("tar".to_string()), diff --git a/src/extractors/trx.rs b/src/extractors/trx.rs index 36bb89b0..11d62782 100644 --- a/src/extractors/trx.rs +++ b/src/extractors/trx.rs @@ -3,6 +3,27 @@ use crate::extractors::common::{Chroot, ExtractionResult, Extractor, ExtractorTy use crate::structures::trx::parse_trx_header; /// Defines the internal TRX extractor +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::trx::trx_extractor; +/// +/// match trx_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn trx_extractor() -> Extractor { Extractor { utility: ExtractorType::Internal(extract_trx_partitions), diff --git a/src/extractors/ubi.rs b/src/extractors/ubi.rs index 7aa7893f..fcad0861 100644 --- a/src/extractors/ubi.rs +++ b/src/extractors/ubi.rs @@ -1,6 +1,27 @@ use crate::extractors; /// Describes how to run the ubireader_extract_images utility to extract UBI images +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::ubi::ubi_extractor; +/// +/// match ubi_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn ubi_extractor() -> extractors::common::Extractor { extractors::common::Extractor { utility: extractors::common::ExtractorType::External( diff --git a/src/extractors/uefi.rs b/src/extractors/uefi.rs index 0c901a8e..90c51765 100644 --- a/src/extractors/uefi.rs +++ b/src/extractors/uefi.rs @@ -1,6 +1,27 @@ use crate::extractors; -/* Describes how to run the uefi-firmware-parser utility to extract UEFI images */ +/// Describes how to run the uefi-firmware-parser utility to extract UEFI images +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::uefi::uefi_extractor; +/// +/// match uefi_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn uefi_extractor() -> extractors::common::Extractor { extractors::common::Extractor { utility: extractors::common::ExtractorType::External("uefi-firmware-parser".to_string()), diff --git a/src/extractors/uimage.rs b/src/extractors/uimage.rs index 35a1195e..56e54680 100644 --- a/src/extractors/uimage.rs +++ b/src/extractors/uimage.rs @@ -2,6 +2,28 @@ use crate::common::crc32; use crate::extractors::common::{Chroot, ExtractionResult, Extractor, ExtractorType}; use crate::structures::uimage::parse_uimage_header; +/// Describes the internal extractor for carving uImage files to disk +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::uimage::uimage_extractor; +/// +/// match uimage_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn uimage_extractor() -> Extractor { Extractor { utility: ExtractorType::Internal(extract_uimage), diff --git a/src/extractors/vxworks.rs b/src/extractors/vxworks.rs index 07271450..6b8dbe9b 100644 --- a/src/extractors/vxworks.rs +++ b/src/extractors/vxworks.rs @@ -6,6 +6,27 @@ use crate::structures::vxworks::{ use serde_json; /// Describes the VxWorks symbol table extractor +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::vxworks::vxworks_symtab_extractor; +/// +/// match vxworks_symtab_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn vxworks_symtab_extractor() -> Extractor { Extractor { do_not_recurse: true, diff --git a/src/extractors/wince.rs b/src/extractors/wince.rs index 24366140..509db92b 100644 --- a/src/extractors/wince.rs +++ b/src/extractors/wince.rs @@ -3,6 +3,27 @@ use crate::extractors::common::{Chroot, ExtractionResult, Extractor, ExtractorTy use crate::structures::wince::{parse_wince_block_header, parse_wince_header}; /// Defines the internal extractor function for extracting Windows CE images +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::wince::wince_extractor; +/// +/// match wince_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn wince_extractor() -> Extractor { Extractor { utility: ExtractorType::Internal(wince_dump), diff --git a/src/extractors/yaffs2.rs b/src/extractors/yaffs2.rs index 4e514fba..d8b1f631 100644 --- a/src/extractors/yaffs2.rs +++ b/src/extractors/yaffs2.rs @@ -1,6 +1,27 @@ use crate::extractors; /// Describes how to run the unyaffs utility to extract YAFFS2 file systems +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::yaffs2::yaffs2_extractor; +/// +/// match yaffs2_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn yaffs2_extractor() -> extractors::common::Extractor { extractors::common::Extractor { utility: extractors::common::ExtractorType::External("unyaffs".to_string()), diff --git a/src/extractors/zlib.rs b/src/extractors/zlib.rs index 513ade44..e6d99bd9 100644 --- a/src/extractors/zlib.rs +++ b/src/extractors/zlib.rs @@ -5,6 +5,27 @@ use crate::extractors::inflate; pub const CHECKSUM_SIZE: usize = 4; /// Defines the internal extractor function for decompressing zlib data +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::zlib::zlib_extractor; +/// +/// match zlib_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn zlib_extractor() -> Extractor { Extractor { utility: ExtractorType::Internal(zlib_decompress), diff --git a/src/extractors/zstd.rs b/src/extractors/zstd.rs index c7632a61..8cf1fec9 100644 --- a/src/extractors/zstd.rs +++ b/src/extractors/zstd.rs @@ -1,6 +1,27 @@ use crate::extractors; /// Describes how to run the zstd utility to extract ZSTD compressed files +/// +/// ``` +/// use std::io::ErrorKind; +/// use std::process::Command; +/// use binwalk::extractors::common::ExtractorType; +/// use binwalk::extractors::zstd::zstd_extractor; +/// +/// match zstd_extractor().utility { +/// ExtractorType::None => panic!("Invalid extractor type of None"), +/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func), +/// ExtractorType::External(cmd) => { +/// if let Err(e) = Command::new(&cmd).output() { +/// if e.kind() == ErrorKind::NotFound { +/// panic!("External extractor '{}' not found", cmd); +/// } else { +/// panic!("Failed to execute external extractor '{}': {}", cmd, e); +/// } +/// } +/// } +/// } +/// ``` pub fn zstd_extractor() -> extractors::common::Extractor { extractors::common::Extractor { utility: extractors::common::ExtractorType::External("zstd".to_string()),