Skip to content

Commit

Permalink
Add defaults for FileSystem generic parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalh committed May 4, 2024
1 parent 9bf887d commit 36b566d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl FileSystemStats {
/// A FAT filesystem object.
///
/// `FileSystem` struct is representing a state of a mounted FAT volume.
pub struct FileSystem<IO: ReadWriteSeek, TP, OCC> {
pub struct FileSystem<IO: ReadWriteSeek, TP = DefaultTimeProvider, OCC = LossyOemCpConverter> {
pub(crate) disk: RefCell<IO>,
pub(crate) options: FsOptions<TP, OCC>,
fat_type: FatType,
Expand Down
5 changes: 2 additions & 3 deletions tests/format.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use std::io;
use std::io::prelude::*;

use fatfs::{DefaultTimeProvider, LossyOemCpConverter, StdIoWrapper};
use fatfs::StdIoWrapper;
use fscommon::BufStream;

const KB: u64 = 1024;
const MB: u64 = KB * 1024;
const TEST_STR: &str = "Hi there Rust programmer!\n";

type FileSystem =
fatfs::FileSystem<StdIoWrapper<BufStream<io::Cursor<Vec<u8>>>>, DefaultTimeProvider, LossyOemCpConverter>;
type FileSystem = fatfs::FileSystem<StdIoWrapper<BufStream<io::Cursor<Vec<u8>>>>>;

fn basic_fs_test(fs: &FileSystem) {
let stats = fs.stats().expect("stats");
Expand Down
4 changes: 2 additions & 2 deletions tests/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use std::io::prelude::*;
use std::io::SeekFrom;
use std::str;

use fatfs::{DefaultTimeProvider, FatType, FsOptions, LossyOemCpConverter, StdIoWrapper};
use fatfs::{FatType, FsOptions, StdIoWrapper};
use fscommon::BufStream;

const TEST_TEXT: &str = "Rust is cool!\n";
const FAT12_IMG: &str = "resources/fat12.img";
const FAT16_IMG: &str = "resources/fat16.img";
const FAT32_IMG: &str = "resources/fat32.img";

type FileSystem = fatfs::FileSystem<StdIoWrapper<BufStream<fs::File>>, DefaultTimeProvider, LossyOemCpConverter>;
type FileSystem = fatfs::FileSystem<StdIoWrapper<BufStream<fs::File>>>;

fn call_with_fs<F: Fn(FileSystem)>(f: F, filename: &str) {
let _ = env_logger::builder().is_test(true).try_init();
Expand Down
4 changes: 2 additions & 2 deletions tests/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::prelude::*;
use std::mem;
use std::str;

use fatfs::{DefaultTimeProvider, FsOptions, LossyOemCpConverter, StdIoWrapper};
use fatfs::{FsOptions, StdIoWrapper};
use fscommon::BufStream;

const FAT12_IMG: &str = "fat12.img";
Expand All @@ -15,7 +15,7 @@ const TMP_DIR: &str = "tmp";
const TEST_STR: &str = "Hi there Rust programmer!\n";
const TEST_STR2: &str = "Rust is cool!\n";

type FileSystem = fatfs::FileSystem<StdIoWrapper<BufStream<fs::File>>, DefaultTimeProvider, LossyOemCpConverter>;
type FileSystem = fatfs::FileSystem<StdIoWrapper<BufStream<fs::File>>>;

fn call_with_tmp_img<F: Fn(&str)>(f: F, filename: &str, test_seq: u32) {
let _ = env_logger::builder().is_test(true).try_init();
Expand Down

0 comments on commit 36b566d

Please sign in to comment.