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:
authorColin Finck <colin@reactos.org>2021-10-03 21:05:07 +0300
committerColin Finck <colin@reactos.org>2021-10-03 21:05:07 +0300
commit8d974038adaebaf763b44b962942d5c5f3f3fcd0 (patch)
tree5048bf4e8ade2197d14d976fe2637f421882dc46
parent2edaaff8bdda1ae6f0858f7b87ce3ab2f2f97c47 (diff)
`NtfsValue` -> `NtfsAttributeValue` and `Slice` -> `Resident`.
Turns out that we won't use this enum for anything else than attribute values, and `Slice` always corresponds to a resident attribute value, so reflect that in the naming. Index keys still use slices without this enum.
-rw-r--r--examples/ntfs-shell/main.rs4
-rw-r--r--src/attribute.rs22
-rw-r--r--src/attribute_value/attribute_list_non_resident.rs (renamed from src/value/attribute_list_non_resident_attribute.rs)2
-rw-r--r--src/attribute_value/mod.rs (renamed from src/value/mod.rs)73
-rw-r--r--src/attribute_value/non_resident.rs (renamed from src/value/non_resident_attribute.rs)0
-rw-r--r--src/attribute_value/resident.rs (renamed from src/value/slice.rs)6
-rw-r--r--src/index_record.rs4
-rw-r--r--src/lib.rs2
-rw-r--r--src/structured_values/attribute_list.rs11
-rw-r--r--src/structured_values/file_name.rs4
-rw-r--r--src/structured_values/index_allocation.rs12
-rw-r--r--src/structured_values/index_root.rs15
-rw-r--r--src/structured_values/mod.rs9
-rw-r--r--src/structured_values/object_id.rs7
-rw-r--r--src/structured_values/standard_information.rs7
-rw-r--r--src/structured_values/volume_information.rs7
-rw-r--r--src/structured_values/volume_name.rs7
17 files changed, 93 insertions, 99 deletions
diff --git a/examples/ntfs-shell/main.rs b/examples/ntfs-shell/main.rs
index 988f675..3df1b59 100644
--- a/examples/ntfs-shell/main.rs
+++ b/examples/ntfs-shell/main.rs
@@ -10,11 +10,11 @@ use std::io::{BufReader, Read, Seek, Write};
use anyhow::{anyhow, bail, Context, Result};
use chrono::{DateTime, Utc};
+use ntfs::attribute_value::NtfsAttributeValue;
use ntfs::indexes::NtfsFileNameIndex;
use ntfs::structured_values::{
NtfsAttributeList, NtfsFileName, NtfsFileNamespace, NtfsStandardInformation,
};
-use ntfs::value::NtfsValue;
use ntfs::{Ntfs, NtfsAttribute, NtfsAttributeType, NtfsFile, NtfsReadSeek};
use sector_reader::SectorReader;
@@ -176,7 +176,7 @@ fn attr_print_attribute<'n>(
);
if with_runs {
- if let NtfsValue::NonResidentAttribute(non_resident_value) = attribute.value()? {
+ if let NtfsAttributeValue::NonResident(non_resident_value) = attribute.value()? {
for (i, data_run) in non_resident_value.data_runs().enumerate() {
let data_run = data_run?;
let instance = format!("{}{}", data_run_prefix, i);
diff --git a/src/attribute.rs b/src/attribute.rs
index 567acd1..a4b6ae3 100644
--- a/src/attribute.rs
+++ b/src/attribute.rs
@@ -1,6 +1,10 @@
// Copyright 2021 Colin Finck <colin@reactos.org>
// SPDX-License-Identifier: GPL-2.0-or-later
+use crate::attribute_value::{
+ NtfsAttributeListNonResidentAttributeValue, NtfsAttributeValue, NtfsNonResidentAttributeValue,
+ NtfsResidentAttributeValue,
+};
use crate::error::{NtfsError, Result};
use crate::file::NtfsFile;
use crate::string::NtfsString;
@@ -9,10 +13,6 @@ use crate::structured_values::{
NtfsStructuredValueFromResidentAttributeValue,
};
use crate::types::Vcn;
-use crate::value::attribute_list_non_resident_attribute::NtfsAttributeListNonResidentAttributeValue;
-use crate::value::non_resident_attribute::NtfsNonResidentAttributeValue;
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use binread::io::{Read, Seek};
use bitflags::bitflags;
use byteorder::{ByteOrder, LittleEndian};
@@ -271,7 +271,7 @@ impl<'n, 'f> NtfsAttribute<'n, 'f> {
S::from_resident_attribute_value(resident_value)
}
- pub(crate) fn resident_value(&self) -> Result<NtfsSliceValue<'f>> {
+ pub(crate) fn resident_value(&self) -> Result<NtfsResidentAttributeValue<'f>> {
debug_assert!(self.is_resident());
self.validate_resident_value_sizes()?;
@@ -279,7 +279,7 @@ impl<'n, 'f> NtfsAttribute<'n, 'f> {
let end = start + self.resident_value_length() as usize;
let data = &self.file.record_data()[start..end];
- Ok(NtfsSliceValue::new(data, self.position()))
+ Ok(NtfsResidentAttributeValue::new(data, self.position()))
}
fn resident_value_length(&self) -> u32 {
@@ -308,7 +308,7 @@ impl<'n, 'f> NtfsAttribute<'n, 'f> {
});
}
- S::from_value(fs, self.value()?)
+ S::from_attribute_value(fs, self.value()?)
}
/// Returns the type of this NTFS attribute, or [`NtfsError::UnsupportedAttributeType`]
@@ -370,7 +370,7 @@ impl<'n, 'f> NtfsAttribute<'n, 'f> {
}
/// Returns an [`NtfsAttributeValue`] structure to read the value of this NTFS attribute.
- pub fn value(&self) -> Result<NtfsValue<'n, 'f>> {
+ pub fn value(&self) -> Result<NtfsAttributeValue<'n, 'f>> {
if let Some(list_entries) = self.list_entries {
// The first attribute reports the entire data size for all connected attributes
// (remaining ones are set to zero).
@@ -384,13 +384,13 @@ impl<'n, 'f> NtfsAttribute<'n, 'f> {
self.ty()?,
data_size,
);
- Ok(NtfsValue::AttributeListNonResidentAttribute(value))
+ Ok(NtfsAttributeValue::AttributeListNonResident(value))
} else if self.is_resident() {
let value = self.resident_value()?;
- Ok(NtfsValue::Slice(value))
+ Ok(NtfsAttributeValue::Resident(value))
} else {
let value = self.non_resident_value()?;
- Ok(NtfsValue::NonResidentAttribute(value))
+ Ok(NtfsAttributeValue::NonResident(value))
}
}
diff --git a/src/value/attribute_list_non_resident_attribute.rs b/src/attribute_value/attribute_list_non_resident.rs
index 8e75724..f85bec6 100644
--- a/src/value/attribute_list_non_resident_attribute.rs
+++ b/src/attribute_value/attribute_list_non_resident.rs
@@ -10,13 +10,13 @@
// Connected attributes are stored in a way that the first attribute reports the entire data size and all further attributes report a zero value length.
// We have to go down to the data run level to get trustable lengths again, and this is what `NtfsAttributeListNonResidentAttributeValue` does here.
+use super::{DataRunsState, NtfsDataRuns, StreamState};
use crate::attribute::{NtfsAttribute, NtfsAttributeType};
use crate::error::{NtfsError, Result};
use crate::file::NtfsFile;
use crate::ntfs::Ntfs;
use crate::structured_values::{NtfsAttributeListEntries, NtfsAttributeListEntry};
use crate::traits::NtfsReadSeek;
-use crate::value::non_resident_attribute::{DataRunsState, NtfsDataRuns, StreamState};
use binread::io::{Read, Seek, SeekFrom};
#[derive(Clone, Debug)]
diff --git a/src/value/mod.rs b/src/attribute_value/mod.rs
index fb39a42..f7f359f 100644
--- a/src/value/mod.rs
+++ b/src/attribute_value/mod.rs
@@ -1,60 +1,61 @@
// Copyright 2021 Colin Finck <colin@reactos.org>
// SPDX-License-Identifier: GPL-2.0-or-later
-pub(crate) mod attribute_list_non_resident_attribute;
-pub(crate) mod non_resident_attribute;
-pub(crate) mod slice;
+mod attribute_list_non_resident;
+mod non_resident;
+mod resident;
+
+pub use attribute_list_non_resident::*;
+pub use non_resident::*;
+pub use resident::*;
use binread::io;
use binread::io::{Read, Seek, SeekFrom};
use crate::error::{NtfsError, Result};
use crate::traits::NtfsReadSeek;
-use attribute_list_non_resident_attribute::NtfsAttributeListNonResidentAttributeValue;
-use non_resident_attribute::NtfsNonResidentAttributeValue;
-use slice::NtfsSliceValue;
#[derive(Clone, Debug)]
-pub enum NtfsValue<'n, 'f> {
- Slice(NtfsSliceValue<'f>),
- NonResidentAttribute(NtfsNonResidentAttributeValue<'n, 'f>),
- AttributeListNonResidentAttribute(NtfsAttributeListNonResidentAttributeValue<'n, 'f>),
+pub enum NtfsAttributeValue<'n, 'f> {
+ Resident(NtfsResidentAttributeValue<'f>),
+ NonResident(NtfsNonResidentAttributeValue<'n, 'f>),
+ AttributeListNonResident(NtfsAttributeListNonResidentAttributeValue<'n, 'f>),
}
-impl<'n, 'f> NtfsValue<'n, 'f> {
- pub fn attach<'a, T>(self, fs: &'a mut T) -> NtfsValueAttached<'n, 'f, 'a, T>
+impl<'n, 'f> NtfsAttributeValue<'n, 'f> {
+ pub fn attach<'a, T>(self, fs: &'a mut T) -> NtfsAttributeValueAttached<'n, 'f, 'a, T>
where
T: Read + Seek,
{
- NtfsValueAttached::new(fs, self)
+ NtfsAttributeValueAttached::new(fs, self)
}
pub fn data_position(&self) -> Option<u64> {
match self {
- Self::Slice(inner) => inner.data_position(),
- Self::NonResidentAttribute(inner) => inner.data_position(),
- Self::AttributeListNonResidentAttribute(inner) => inner.data_position(),
+ Self::Resident(inner) => inner.data_position(),
+ Self::NonResident(inner) => inner.data_position(),
+ Self::AttributeListNonResident(inner) => inner.data_position(),
}
}
pub fn len(&self) -> u64 {
match self {
- Self::Slice(inner) => inner.len(),
- Self::NonResidentAttribute(inner) => inner.len(),
- Self::AttributeListNonResidentAttribute(inner) => inner.len(),
+ Self::Resident(inner) => inner.len(),
+ Self::NonResident(inner) => inner.len(),
+ Self::AttributeListNonResident(inner) => inner.len(),
}
}
}
-impl<'n, 'f> NtfsReadSeek for NtfsValue<'n, 'f> {
+impl<'n, 'f> NtfsReadSeek for NtfsAttributeValue<'n, 'f> {
fn read<T>(&mut self, fs: &mut T, buf: &mut [u8]) -> Result<usize>
where
T: Read + Seek,
{
match self {
- Self::Slice(inner) => inner.read(fs, buf),
- Self::NonResidentAttribute(inner) => inner.read(fs, buf),
- Self::AttributeListNonResidentAttribute(inner) => inner.read(fs, buf),
+ Self::Resident(inner) => inner.read(fs, buf),
+ Self::NonResident(inner) => inner.read(fs, buf),
+ Self::AttributeListNonResident(inner) => inner.read(fs, buf),
}
}
@@ -63,31 +64,31 @@ impl<'n, 'f> NtfsReadSeek for NtfsValue<'n, 'f> {
T: Read + Seek,
{
match self {
- Self::Slice(inner) => inner.seek(fs, pos),
- Self::NonResidentAttribute(inner) => inner.seek(fs, pos),
- Self::AttributeListNonResidentAttribute(inner) => inner.seek(fs, pos),
+ Self::Resident(inner) => inner.seek(fs, pos),
+ Self::NonResident(inner) => inner.seek(fs, pos),
+ Self::AttributeListNonResident(inner) => inner.seek(fs, pos),
}
}
fn stream_position(&self) -> u64 {
match self {
- Self::Slice(inner) => inner.stream_position(),
- Self::NonResidentAttribute(inner) => inner.stream_position(),
- Self::AttributeListNonResidentAttribute(inner) => inner.stream_position(),
+ Self::Resident(inner) => inner.stream_position(),
+ Self::NonResident(inner) => inner.stream_position(),
+ Self::AttributeListNonResident(inner) => inner.stream_position(),
}
}
}
-pub struct NtfsValueAttached<'n, 'f, 'a, T: Read + Seek> {
+pub struct NtfsAttributeValueAttached<'n, 'f, 'a, T: Read + Seek> {
fs: &'a mut T,
- value: NtfsValue<'n, 'f>,
+ value: NtfsAttributeValue<'n, 'f>,
}
-impl<'n, 'f, 'a, T> NtfsValueAttached<'n, 'f, 'a, T>
+impl<'n, 'f, 'a, T> NtfsAttributeValueAttached<'n, 'f, 'a, T>
where
T: Read + Seek,
{
- fn new(fs: &'a mut T, value: NtfsValue<'n, 'f>) -> Self {
+ fn new(fs: &'a mut T, value: NtfsAttributeValue<'n, 'f>) -> Self {
Self { fs, value }
}
@@ -95,7 +96,7 @@ where
self.value.data_position()
}
- pub fn detach(self) -> NtfsValue<'n, 'f> {
+ pub fn detach(self) -> NtfsAttributeValue<'n, 'f> {
self.value
}
@@ -104,7 +105,7 @@ where
}
}
-impl<'n, 'f, 'a, T> Read for NtfsValueAttached<'n, 'f, 'a, T>
+impl<'n, 'f, 'a, T> Read for NtfsAttributeValueAttached<'n, 'f, 'a, T>
where
T: Read + Seek,
{
@@ -113,7 +114,7 @@ where
}
}
-impl<'n, 'f, 'a, T> Seek for NtfsValueAttached<'n, 'f, 'a, T>
+impl<'n, 'f, 'a, T> Seek for NtfsAttributeValueAttached<'n, 'f, 'a, T>
where
T: Read + Seek,
{
diff --git a/src/value/non_resident_attribute.rs b/src/attribute_value/non_resident.rs
index 4639261..4639261 100644
--- a/src/value/non_resident_attribute.rs
+++ b/src/attribute_value/non_resident.rs
diff --git a/src/value/slice.rs b/src/attribute_value/resident.rs
index abfb0f9..a81fb8f 100644
--- a/src/value/slice.rs
+++ b/src/attribute_value/resident.rs
@@ -14,13 +14,13 @@ use crate::error::Result;
use crate::traits::NtfsReadSeek;
#[derive(Clone, Debug)]
-pub struct NtfsSliceValue<'f> {
+pub struct NtfsResidentAttributeValue<'f> {
data: &'f [u8],
position: u64,
stream_position: u64,
}
-impl<'f> NtfsSliceValue<'f> {
+impl<'f> NtfsResidentAttributeValue<'f> {
pub(crate) fn new(data: &'f [u8], position: u64) -> Self {
Self {
data,
@@ -52,7 +52,7 @@ impl<'f> NtfsSliceValue<'f> {
}
}
-impl<'f> NtfsReadSeek for NtfsSliceValue<'f> {
+impl<'f> NtfsReadSeek for NtfsResidentAttributeValue<'f> {
fn read<T>(&mut self, _fs: &mut T, buf: &mut [u8]) -> Result<usize>
where
T: Read + Seek,
diff --git a/src/index_record.rs b/src/index_record.rs
index 4c4978a..d73827d 100644
--- a/src/index_record.rs
+++ b/src/index_record.rs
@@ -1,6 +1,7 @@
// Copyright 2021 Colin Finck <colin@reactos.org>
// SPDX-License-Identifier: GPL-2.0-or-later
+use crate::attribute_value::NtfsAttributeValue;
use crate::error::{NtfsError, Result};
use crate::index_entry::{IndexNodeEntryRanges, NtfsIndexNodeEntries};
use crate::indexes::NtfsIndexEntryType;
@@ -9,7 +10,6 @@ use crate::record::Record;
use crate::record::RecordHeader;
use crate::traits::NtfsReadSeek;
use crate::types::Vcn;
-use crate::value::NtfsValue;
use binread::io::{Read, Seek};
use byteorder::{ByteOrder, LittleEndian};
use core::ops::Range;
@@ -46,7 +46,7 @@ impl<'n> NtfsIndexRecord<'n> {
pub(crate) fn new<T>(
ntfs: &'n Ntfs,
fs: &mut T,
- mut value: NtfsValue<'n, '_>,
+ mut value: NtfsAttributeValue<'n, '_>,
index_record_size: u32,
) -> Result<Self>
where
diff --git a/src/lib.rs b/src/lib.rs
index 7eef943..e32b5f0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,6 +10,7 @@ extern crate alloc;
mod helpers;
mod attribute;
+pub mod attribute_value;
mod boot_sector;
mod error;
mod file;
@@ -27,7 +28,6 @@ mod time;
mod traits;
mod types;
mod upcase_table;
-pub mod value;
pub use crate::attribute::*;
pub use crate::error::*;
diff --git a/src/structured_values/attribute_list.rs b/src/structured_values/attribute_list.rs
index 27b502f..e336e84 100644
--- a/src/structured_values/attribute_list.rs
+++ b/src/structured_values/attribute_list.rs
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::{NtfsAttribute, NtfsAttributeType};
+use crate::attribute_value::{NtfsAttributeValue, NtfsNonResidentAttributeValue};
use crate::error::{NtfsError, Result};
use crate::file::NtfsFile;
use crate::file_reference::NtfsFileReference;
@@ -10,8 +11,6 @@ use crate::string::NtfsString;
use crate::structured_values::NtfsStructuredValue;
use crate::traits::NtfsReadSeek;
use crate::types::Vcn;
-use crate::value::non_resident_attribute::NtfsNonResidentAttributeValue;
-use crate::value::NtfsValue;
use arrayvec::ArrayVec;
use binread::io::{Cursor, Read, Seek, SeekFrom};
use binread::{BinRead, BinReaderExt};
@@ -67,18 +66,18 @@ impl<'n, 'f> NtfsAttributeList<'n, 'f> {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsAttributeList<'n, 'f> {
const TY: NtfsAttributeType = NtfsAttributeType::AttributeList;
- fn from_value<T>(_fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(_fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
match value {
- NtfsValue::Slice(value) => {
+ NtfsAttributeValue::Resident(value) => {
let slice = value.data();
let position = value.data_position().unwrap();
Ok(Self::Resident(slice, position))
}
- NtfsValue::NonResidentAttribute(value) => Ok(Self::NonResident(value)),
- NtfsValue::AttributeListNonResidentAttribute(value) => {
+ NtfsAttributeValue::NonResident(value) => Ok(Self::NonResident(value)),
+ NtfsAttributeValue::AttributeListNonResident(value) => {
// Attribute Lists are never nested.
// Hence, we must not create this attribute from an attribute that is already part of Attribute List.
let position = value.data_position().unwrap();
diff --git a/src/structured_values/file_name.rs b/src/structured_values/file_name.rs
index 3628495..056bfa3 100644
--- a/src/structured_values/file_name.rs
+++ b/src/structured_values/file_name.rs
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::NtfsAttributeValue;
use crate::error::{NtfsError, Result};
use crate::file_reference::NtfsFileReference;
use crate::indexes::NtfsIndexEntryKey;
use crate::string::NtfsString;
use crate::structured_values::{NtfsFileAttributeFlags, NtfsStructuredValue};
use crate::time::NtfsTime;
-use crate::value::NtfsValue;
use arrayvec::ArrayVec;
use binread::io::{Cursor, Read, Seek};
use binread::{BinRead, BinReaderExt};
@@ -180,7 +180,7 @@ impl NtfsFileName {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsFileName {
const TY: NtfsAttributeType = NtfsAttributeType::FileName;
- fn from_value<T>(fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
diff --git a/src/structured_values/index_allocation.rs b/src/structured_values/index_allocation.rs
index 0f6742d..01da45d 100644
--- a/src/structured_values/index_allocation.rs
+++ b/src/structured_values/index_allocation.rs
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::NtfsAttributeValue;
use crate::error::{NtfsError, Result};
use crate::index_record::NtfsIndexRecord;
use crate::ntfs::Ntfs;
@@ -9,14 +10,13 @@ use crate::structured_values::index_root::NtfsIndexRoot;
use crate::structured_values::NtfsStructuredValue;
use crate::traits::NtfsReadSeek;
use crate::types::Vcn;
-use crate::value::NtfsValue;
use binread::io::{Read, Seek, SeekFrom};
use core::iter::FusedIterator;
#[derive(Clone, Debug)]
pub struct NtfsIndexAllocation<'n, 'f> {
ntfs: &'n Ntfs,
- value: NtfsValue<'n, 'f>,
+ value: NtfsAttributeValue<'n, 'f>,
}
impl<'n, 'f> NtfsIndexAllocation<'n, 'f> {
@@ -66,14 +66,14 @@ impl<'n, 'f> NtfsIndexAllocation<'n, 'f> {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsIndexAllocation<'n, 'f> {
const TY: NtfsAttributeType = NtfsAttributeType::IndexAllocation;
- fn from_value<T>(_fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(_fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
let ntfs = match &value {
- NtfsValue::AttributeListNonResidentAttribute(value) => value.ntfs(),
- NtfsValue::NonResidentAttribute(value) => value.ntfs(),
- NtfsValue::Slice(_) => {
+ NtfsAttributeValue::AttributeListNonResident(value) => value.ntfs(),
+ NtfsAttributeValue::NonResident(value) => value.ntfs(),
+ NtfsAttributeValue::Resident(_) => {
let position = value.data_position().unwrap();
return Err(NtfsError::UnexpectedResidentAttribute { position });
}
diff --git a/src/structured_values/index_root.rs b/src/structured_values/index_root.rs
index 9c1cb2f..86a12af 100644
--- a/src/structured_values/index_root.rs
+++ b/src/structured_values/index_root.rs
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::{NtfsAttributeValue, NtfsResidentAttributeValue};
use crate::error::{NtfsError, Result};
use crate::index_entry::{IndexNodeEntryRanges, NtfsIndexNodeEntries};
use crate::index_record::{IndexNodeHeader, INDEX_NODE_HEADER_SIZE};
@@ -9,8 +10,6 @@ use crate::indexes::NtfsIndexEntryType;
use crate::structured_values::{
NtfsStructuredValue, NtfsStructuredValueFromResidentAttributeValue,
};
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use binread::io::{Read, Seek};
use byteorder::{ByteOrder, LittleEndian};
use core::ops::Range;
@@ -139,25 +138,25 @@ impl<'f> NtfsIndexRoot<'f> {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsIndexRoot<'f> {
const TY: NtfsAttributeType = NtfsAttributeType::IndexRoot;
- fn from_value<T>(_fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(_fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
- let slice_value = match value {
- NtfsValue::Slice(slice_value) => slice_value,
+ let resident_value = match value {
+ NtfsAttributeValue::Resident(resident_value) => resident_value,
_ => {
let position = value.data_position().unwrap();
return Err(NtfsError::UnexpectedNonResidentAttribute { position });
}
};
- let position = slice_value.data_position().unwrap();
- Self::new(slice_value.data(), position)
+ let position = resident_value.data_position().unwrap();
+ Self::new(resident_value.data(), position)
}
}
impl<'n, 'f> NtfsStructuredValueFromResidentAttributeValue<'n, 'f> for NtfsIndexRoot<'f> {
- fn from_resident_attribute_value(value: NtfsSliceValue<'f>) -> Result<Self> {
+ fn from_resident_attribute_value(value: NtfsResidentAttributeValue<'f>) -> Result<Self> {
Self::new(value.data(), value.data_position().unwrap())
}
}
diff --git a/src/structured_values/mod.rs b/src/structured_values/mod.rs
index c965516..d8fcc0d 100644
--- a/src/structured_values/mod.rs
+++ b/src/structured_values/mod.rs
@@ -22,9 +22,8 @@ pub use volume_information::*;
pub use volume_name::*;
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::{NtfsAttributeValue, NtfsResidentAttributeValue};
use crate::error::Result;
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use binread::io::{Read, Seek};
use bitflags::bitflags;
@@ -50,8 +49,8 @@ bitflags! {
pub trait NtfsStructuredValue<'n, 'f>: Sized {
const TY: NtfsAttributeType;
- /// Create a structured value from an arbitrary `NtfsValue`.
- fn from_value<T>(fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ /// Create a structured value from an arbitrary `NtfsAttributeValue`.
+ fn from_attribute_value<T>(fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek;
}
@@ -61,5 +60,5 @@ pub trait NtfsStructuredValue<'n, 'f>: Sized {
pub trait NtfsStructuredValueFromResidentAttributeValue<'n, 'f>:
NtfsStructuredValue<'n, 'f>
{
- fn from_resident_attribute_value(value: NtfsSliceValue<'f>) -> Result<Self>;
+ fn from_resident_attribute_value(value: NtfsResidentAttributeValue<'f>) -> Result<Self>;
}
diff --git a/src/structured_values/object_id.rs b/src/structured_values/object_id.rs
index 1efec3a..3f03cc6 100644
--- a/src/structured_values/object_id.rs
+++ b/src/structured_values/object_id.rs
@@ -2,13 +2,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::{NtfsAttributeValue, NtfsResidentAttributeValue};
use crate::error::{NtfsError, Result};
use crate::guid::{NtfsGuid, GUID_SIZE};
use crate::structured_values::{
NtfsStructuredValue, NtfsStructuredValueFromResidentAttributeValue,
};
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use binread::io::{Cursor, Read, Seek};
use binread::BinReaderExt;
@@ -79,7 +78,7 @@ impl NtfsObjectId {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsObjectId {
const TY: NtfsAttributeType = NtfsAttributeType::ObjectId;
- fn from_value<T>(fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
@@ -92,7 +91,7 @@ impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsObjectId {
}
impl<'n, 'f> NtfsStructuredValueFromResidentAttributeValue<'n, 'f> for NtfsObjectId {
- fn from_resident_attribute_value(value: NtfsSliceValue<'f>) -> Result<Self> {
+ fn from_resident_attribute_value(value: NtfsResidentAttributeValue<'f>) -> Result<Self> {
let position = value.data_position().unwrap();
let value_length = value.len();
diff --git a/src/structured_values/standard_information.rs b/src/structured_values/standard_information.rs
index 01a1771..5ae8891 100644
--- a/src/structured_values/standard_information.rs
+++ b/src/structured_values/standard_information.rs
@@ -2,13 +2,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::{NtfsAttributeValue, NtfsResidentAttributeValue};
use crate::error::{NtfsError, Result};
use crate::structured_values::{
NtfsFileAttributeFlags, NtfsStructuredValue, NtfsStructuredValueFromResidentAttributeValue,
};
use crate::time::NtfsTime;
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use binread::io::{Cursor, Read, Seek};
use binread::{BinRead, BinReaderExt};
@@ -123,7 +122,7 @@ impl NtfsStandardInformation {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsStandardInformation {
const TY: NtfsAttributeType = NtfsAttributeType::StandardInformation;
- fn from_value<T>(fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
@@ -136,7 +135,7 @@ impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsStandardInformation {
}
impl<'n, 'f> NtfsStructuredValueFromResidentAttributeValue<'n, 'f> for NtfsStandardInformation {
- fn from_resident_attribute_value(value: NtfsSliceValue<'f>) -> Result<Self> {
+ fn from_resident_attribute_value(value: NtfsResidentAttributeValue<'f>) -> Result<Self> {
let position = value.data_position().unwrap();
let value_length = value.len();
diff --git a/src/structured_values/volume_information.rs b/src/structured_values/volume_information.rs
index ea235ac..ff16018 100644
--- a/src/structured_values/volume_information.rs
+++ b/src/structured_values/volume_information.rs
@@ -2,12 +2,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::{NtfsAttributeValue, NtfsResidentAttributeValue};
use crate::error::{NtfsError, Result};
use crate::structured_values::{
NtfsStructuredValue, NtfsStructuredValueFromResidentAttributeValue,
};
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use binread::io::{Cursor, Read, Seek};
use binread::{BinRead, BinReaderExt};
use bitflags::bitflags;
@@ -77,7 +76,7 @@ impl NtfsVolumeInformation {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsVolumeInformation {
const TY: NtfsAttributeType = NtfsAttributeType::VolumeInformation;
- fn from_value<T>(fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
@@ -90,7 +89,7 @@ impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsVolumeInformation {
}
impl<'n, 'f> NtfsStructuredValueFromResidentAttributeValue<'n, 'f> for NtfsVolumeInformation {
- fn from_resident_attribute_value(value: NtfsSliceValue<'f>) -> Result<Self> {
+ fn from_resident_attribute_value(value: NtfsResidentAttributeValue<'f>) -> Result<Self> {
let position = value.data_position().unwrap();
let value_length = value.len();
diff --git a/src/structured_values/volume_name.rs b/src/structured_values/volume_name.rs
index ce51386..b2cc823 100644
--- a/src/structured_values/volume_name.rs
+++ b/src/structured_values/volume_name.rs
@@ -2,13 +2,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later
use crate::attribute::NtfsAttributeType;
+use crate::attribute_value::{NtfsAttributeValue, NtfsResidentAttributeValue};
use crate::error::{NtfsError, Result};
use crate::string::NtfsString;
use crate::structured_values::{
NtfsStructuredValue, NtfsStructuredValueFromResidentAttributeValue,
};
-use crate::value::slice::NtfsSliceValue;
-use crate::value::NtfsValue;
use arrayvec::ArrayVec;
use binread::io::{Cursor, Read, Seek};
use core::mem;
@@ -70,7 +69,7 @@ impl NtfsVolumeName {
impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsVolumeName {
const TY: NtfsAttributeType = NtfsAttributeType::VolumeName;
- fn from_value<T>(fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
+ fn from_attribute_value<T>(fs: &mut T, value: NtfsAttributeValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
@@ -83,7 +82,7 @@ impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsVolumeName {
}
impl<'n, 'f> NtfsStructuredValueFromResidentAttributeValue<'n, 'f> for NtfsVolumeName {
- fn from_resident_attribute_value(value: NtfsSliceValue<'f>) -> Result<Self> {
+ fn from_resident_attribute_value(value: NtfsResidentAttributeValue<'f>) -> Result<Self> {
let position = value.data_position().unwrap();
let value_length = value.len();