Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/ntfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/indexes/mod.rs')
-rw-r--r--src/indexes/mod.rs34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/indexes/mod.rs b/src/indexes/mod.rs
index ba3508c..2d80ff0 100644
--- a/src/indexes/mod.rs
+++ b/src/indexes/mod.rs
@@ -1,5 +1,18 @@
// Copyright 2021 Colin Finck <colin@reactos.org>
// SPDX-License-Identifier: GPL-2.0-or-later
+//
+//! Various types of NTFS indexes and traits to work with them.
+//!
+//! Thanks to Rust's typesystem, the traits make using the various types of NTFS indexes (and their distinct key
+//! and data types) possible in a typesafe way.
+//!
+//! NTFS uses B-tree indexes to quickly look up directories, Object IDs, Reparse Points, Security Descriptors, etc.
+//! They are described via [`NtfsIndexRoot`] and [`NtfsIndexAllocation`] attributes, which can be comfortably
+//! accessed via [`NtfsIndex`].
+//!
+//! [`NtfsIndex`]: crate::NtfsIndex
+//! [`NtfsIndexAllocation`]: crate::structured_values::NtfsIndexAllocation
+//! [`NtfsIndexRoot`]: crate::structured_values::NtfsIndexRoot
mod file_name;
@@ -8,24 +21,37 @@ pub use file_name::*;
use crate::error::Result;
use core::fmt;
+/// Trait implemented by structures that describe Index Entry types.
+///
+/// See also [`NtfsIndex`] and [`NtfsIndexEntry`], and [`NtfsFileNameIndex`] for the most popular Index Entry type.
+///
+/// [`NtfsFileNameIndex`]: crate::indexes::NtfsFileNameIndex
+/// [`NtfsIndex`]: crate::NtfsIndex
+/// [`NtfsIndexEntry`]: crate::NtfsIndexEntry
pub trait NtfsIndexEntryType: fmt::Debug {
type KeyType: NtfsIndexEntryKey;
}
+/// Trait implemented by a structure that describes an Index Entry key.
pub trait NtfsIndexEntryKey: fmt::Debug + Sized {
fn key_from_slice(slice: &[u8], position: u64) -> Result<Self>;
}
-/// Indicates that the index entry type has additional data.
-// This would benefit from negative trait bounds, as this trait and `NtfsIndexEntryHasFileReference` are mutually exclusive!
+/// Indicates that the Index Entry type has additional data (of [`NtfsIndexEntryData`] datatype).
+///
+/// This trait and [`NtfsIndexEntryHasFileReference`] are mutually exclusive.
+// TODO: Use negative trait bounds of future Rust to enforce mutual exclusion.
pub trait NtfsIndexEntryHasData: NtfsIndexEntryType {
type DataType: NtfsIndexEntryData;
}
+/// Trait implemented by a structure that describes Index Entry data.
pub trait NtfsIndexEntryData: fmt::Debug + Sized {
fn data_from_slice(slice: &[u8], position: u64) -> Result<Self>;
}
-/// Indicates that the index entry type has a file reference.
-// This would benefit from negative trait bounds, as this trait and `NtfsIndexEntryHasData` are mutually exclusive!
+/// Indicates that the Index Entry type has a file reference.
+///
+/// This trait and [`NtfsIndexEntryHasData`] are mutually exclusive.
+// TODO: Use negative trait bounds of future Rust to enforce mutual exclusion.
pub trait NtfsIndexEntryHasFileReference: NtfsIndexEntryType {}