codebase-labs / icfs

Internet Computer File System
Apache License 2.0
38 stars 4 forks source link

Buffering/caching #24

Open paulyoung opened 2 years ago

paulyoung commented 2 years ago

fatfs recommends using fscommon::BufStream

Note: it is recommended to wrap the underlying file struct in a buffering/caching object like BufStream from fscommon crate. For example:

 let buf_stream = BufStream::new(img_file);
 let fs = fatfs::FileSystem::new(buf_stream, fatfs::FsOptions::new())?;

https://github.com/dfinity/cdk-rs/pull/245 and https://github.com/dfinity/cdk-rs/pull/247 appear to be doing something similar that won’t work out of the box here.

paulyoung commented 2 years ago

See also: BufRead, BufReader, and BufWriter: https://github.com/rust-lang/rust/blob/3d237ab52920924694f6fc3e47ee8588514bfa70/library/std/src/io/mod.rs#L38-L120