Doc improvements

This commit is contained in:
Rafał Harabień 2018-06-17 16:27:59 +02:00
parent 11a39fdaae
commit 8a5491a919

View File

@ -61,9 +61,11 @@ impl FsStatusFlags {
} }
} }
/// Sum of `Read` and `Seek` traits.
pub trait ReadSeek: Read + Seek {} pub trait ReadSeek: Read + Seek {}
impl<T> ReadSeek for T where T: Read + Seek {} impl<T> ReadSeek for T where T: Read + Seek {}
/// Sum of `Read`, `Write` and `Seek` traits.
pub trait ReadWriteSeek: Read + Write + Seek {} pub trait ReadWriteSeek: Read + Write + Seek {}
impl<T> ReadWriteSeek for T where T: Read + Write + Seek {} impl<T> ReadWriteSeek for T where T: Read + Write + Seek {}
@ -306,6 +308,7 @@ pub struct FsOptions {
} }
impl FsOptions { impl FsOptions {
/// Creates `FsOptions` struct with default options.
pub fn new() -> Self { pub fn new() -> Self {
FsOptions { FsOptions {
update_accessed_date: false, update_accessed_date: false,
@ -352,6 +355,8 @@ impl FileSystemStats {
} }
/// FAT filesystem struct. /// FAT filesystem struct.
///
/// `FileSystem` struct is representing a state of a mounted FAT volume.
pub struct FileSystem<T: ReadWriteSeek> { pub struct FileSystem<T: ReadWriteSeek> {
pub(crate) disk: RefCell<T>, pub(crate) disk: RefCell<T>,
pub(crate) options: FsOptions, pub(crate) options: FsOptions,
@ -366,8 +371,9 @@ pub struct FileSystem<T: ReadWriteSeek> {
impl <T: ReadWriteSeek> FileSystem<T> { impl <T: ReadWriteSeek> FileSystem<T> {
/// Creates a new filesystem object instance. /// Creates a new filesystem object instance.
/// ///
/// Supplied `disk` parameter cannot be seeked. If there is a need to read a fragment of disk image (e.g. partition) /// Supplied `disk` parameter cannot be seeked. If there is a need to read a fragment of disk
/// library user should wrap file handle in struct limiting access to partition bytes only e.g. `fscommon::StreamSlice`. /// image (e.g. partition) library user should wrap the file handle in a struct limiting
/// access to partition bytes only e.g. `fscommon::StreamSlice`.
/// ///
/// Note: creating multiple filesystem objects with one underlying device/disk image can /// Note: creating multiple filesystem objects with one underlying device/disk image can
/// cause a filesystem corruption. /// cause a filesystem corruption.
@ -424,7 +430,7 @@ impl <T: ReadWriteSeek> FileSystem<T> {
}) })
} }
/// Returns a type of used File Allocation Table (FAT). /// Returns a type of File Allocation Table (FAT) used by this filesystem.
pub fn fat_type(&self) -> FatType { pub fn fat_type(&self) -> FatType {
self.fat_type self.fat_type
} }
@ -534,7 +540,7 @@ impl <T: ReadWriteSeek> FileSystem<T> {
/// Returns filesystem statistics like number of total and free clusters. /// Returns filesystem statistics like number of total and free clusters.
/// ///
/// For FAT32 volumes number of free clusters from FSInfo sector is returned (may be incorrect). /// For FAT32 volumes number of free clusters from FSInfo sector is returned (may be incorrect).
/// For other filesystems number is computed on first call to this method. /// For other FAT variants number is computed on the first call to this method and cached for later use.
pub fn stats(&self) -> io::Result<FileSystemStats> { pub fn stats(&self) -> io::Result<FileSystemStats> {
let free_clusters_option = self.fs_info.borrow().free_cluster_count; let free_clusters_option = self.fs_info.borrow().free_cluster_count;
let free_clusters = match free_clusters_option { let free_clusters = match free_clusters_option {
@ -582,7 +588,7 @@ impl <T: ReadWriteSeek> FileSystem<T> {
} }
} }
/// Tries to unmoun filesystem when dropping. /// `Drop` implementation tries to unmount the filesystem when dropping.
impl<T: ReadWriteSeek> Drop for FileSystem<T> { impl<T: ReadWriteSeek> Drop for FileSystem<T> {
fn drop(&mut self) { fn drop(&mut self) {
if let Err(err) = self.unmount_internal() { if let Err(err) = self.unmount_internal() {