diff --git a/examples/append_file.rs b/examples/append_file.rs index bbda009..2c7dd8e 100644 --- a/examples/append_file.rs +++ b/examples/append_file.rs @@ -22,7 +22,9 @@ use linux::*; const FILE_TO_APPEND: &str = "README.TXT"; -use embedded_sdmmc::{Error, Mode, VolumeIdx, VolumeManager}; +use embedded_sdmmc::{Error, Mode, VolumeIdx}; + +type VolumeManager = embedded_sdmmc::VolumeManager; fn main() -> Result<(), embedded_sdmmc::Error> { env_logger::init(); @@ -30,8 +32,7 @@ fn main() -> Result<(), embedded_sdmmc::Error> { let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into()); let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false); let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?; - let volume_mgr: VolumeManager = - VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); + let volume_mgr: VolumeManager = VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); let volume = volume_mgr.open_volume(VolumeIdx(0))?; let root_dir = volume.open_root_dir()?; println!("\nCreating file {}...", FILE_TO_APPEND); diff --git a/examples/big_dir.rs b/examples/big_dir.rs index 98ad90a..a017026 100644 --- a/examples/big_dir.rs +++ b/examples/big_dir.rs @@ -3,7 +3,9 @@ extern crate embedded_sdmmc; mod linux; use linux::*; -use embedded_sdmmc::{Error, VolumeManager}; +use embedded_sdmmc::Error; + +type VolumeManager = embedded_sdmmc::VolumeManager; fn main() -> Result<(), embedded_sdmmc::Error> { env_logger::init(); @@ -11,8 +13,7 @@ fn main() -> Result<(), embedded_sdmmc::Error> { let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into()); let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false); let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?; - let volume_mgr: VolumeManager = - VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); + let volume_mgr: VolumeManager = VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); let volume = volume_mgr .open_volume(embedded_sdmmc::VolumeIdx(1)) .unwrap(); diff --git a/examples/create_file.rs b/examples/create_file.rs index fa96d07..cc8b193 100644 --- a/examples/create_file.rs +++ b/examples/create_file.rs @@ -22,7 +22,9 @@ use linux::*; const FILE_TO_CREATE: &str = "CREATE.TXT"; -use embedded_sdmmc::{Error, Mode, VolumeIdx, VolumeManager}; +use embedded_sdmmc::{Error, Mode, VolumeIdx}; + +type VolumeManager = embedded_sdmmc::VolumeManager; fn main() -> Result<(), embedded_sdmmc::Error> { env_logger::init(); @@ -30,8 +32,7 @@ fn main() -> Result<(), embedded_sdmmc::Error> { let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into()); let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false); let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?; - let volume_mgr: VolumeManager = - VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); + let volume_mgr: VolumeManager = VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); let volume = volume_mgr.open_volume(VolumeIdx(0))?; let root_dir = volume.open_root_dir()?; println!("\nCreating file {}...", FILE_TO_CREATE); diff --git a/examples/delete_file.rs b/examples/delete_file.rs index f76d360..4d88213 100644 --- a/examples/delete_file.rs +++ b/examples/delete_file.rs @@ -25,7 +25,9 @@ use linux::*; const FILE_TO_DELETE: &str = "README.TXT"; -use embedded_sdmmc::{Error, VolumeIdx, VolumeManager}; +use embedded_sdmmc::{Error, VolumeIdx}; + +type VolumeManager = embedded_sdmmc::VolumeManager; fn main() -> Result<(), embedded_sdmmc::Error> { env_logger::init(); @@ -33,8 +35,7 @@ fn main() -> Result<(), embedded_sdmmc::Error> { let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into()); let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false); let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?; - let volume_mgr: VolumeManager = - VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); + let volume_mgr: VolumeManager = VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); let volume = volume_mgr.open_volume(VolumeIdx(0))?; let root_dir = volume.open_root_dir()?; println!("Deleting file {}...", FILE_TO_DELETE); diff --git a/examples/list_dir.rs b/examples/list_dir.rs index 60d7294..0057849 100644 --- a/examples/list_dir.rs +++ b/examples/list_dir.rs @@ -32,23 +32,24 @@ //! $ cargo run --example list_dir -- ./disk.img //! ``` -extern crate embedded_sdmmc; - mod linux; use linux::*; -use embedded_sdmmc::{Directory, VolumeIdx, VolumeManager}; +use embedded_sdmmc::{ShortFileName, VolumeIdx}; type Error = embedded_sdmmc::Error; +type Directory<'a> = embedded_sdmmc::Directory<'a, LinuxBlockDevice, Clock, 8, 4, 4>; +type VolumeManager = embedded_sdmmc::VolumeManager; + fn main() -> Result<(), Error> { env_logger::init(); let mut args = std::env::args().skip(1); let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into()); let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false); + let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?; - let volume_mgr: VolumeManager = - VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); + let volume_mgr: VolumeManager = VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); let volume = volume_mgr.open_volume(VolumeIdx(0))?; let root_dir = volume.open_root_dir()?; list_dir(root_dir, "/")?; @@ -58,10 +59,7 @@ fn main() -> Result<(), Error> { /// Recursively print a directory listing for the open directory given. /// /// The path is for display purposes only. -fn list_dir( - directory: Directory, - path: &str, -) -> Result<(), Error> { +fn list_dir(directory: Directory<'_>, path: &str) -> Result<(), Error> { println!("Listing {}", path); let mut children = Vec::new(); directory.iterate_dir(|entry| { @@ -77,8 +75,8 @@ fn list_dir( } ); if entry.attributes.is_directory() - && entry.name != embedded_sdmmc::ShortFileName::parent_dir() - && entry.name != embedded_sdmmc::ShortFileName::this_dir() + && entry.name != ShortFileName::parent_dir() + && entry.name != ShortFileName::this_dir() { children.push(entry.name.clone()); } diff --git a/examples/read_file.rs b/examples/read_file.rs index f962b75..e8d900c 100644 --- a/examples/read_file.rs +++ b/examples/read_file.rs @@ -39,7 +39,9 @@ use linux::*; const FILE_TO_READ: &str = "README.TXT"; -use embedded_sdmmc::{Error, Mode, VolumeIdx, VolumeManager}; +use embedded_sdmmc::{Error, Mode, VolumeIdx}; + +type VolumeManager = embedded_sdmmc::VolumeManager; fn main() -> Result<(), embedded_sdmmc::Error> { env_logger::init(); @@ -47,8 +49,7 @@ fn main() -> Result<(), embedded_sdmmc::Error> { let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into()); let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false); let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?; - let volume_mgr: VolumeManager = - VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); + let volume_mgr: VolumeManager = VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000); let volume = volume_mgr.open_volume(VolumeIdx(0))?; let root_dir = volume.open_root_dir()?; println!("\nReading file {}...", FILE_TO_READ);