Struct ntfs::NtfsAttribute

source ·
pub struct NtfsAttribute<'n, 'f> { /* private fields */ }
Expand description

A single NTFS Attribute of an NtfsFile.

Not to be confused with NtfsFileAttributeFlags.

This structure is returned by the NtfsAttributesRaw iterator as well as NtfsAttributeItem::to_attribute.

Reference: https://flatcap.github.io/linux-ntfs/ntfs/concepts/attribute_header.html

Implementations§

source§

impl<'n, 'f> NtfsAttribute<'n, 'f>

source

pub fn attribute_length(&self) -> u32

Returns the length of this NTFS Attribute, in bytes.

This denotes the length of the attribute structure on disk. Apart from various headers, this structure also includes the name and, for resident attributes, the actual value.

source

pub fn flags(&self) -> NtfsAttributeFlags

Returns flags set for this attribute as specified by NtfsAttributeFlags.

source

pub fn instance(&self) -> u16

Returns the identifier of this attribute that is unique within the NtfsFile.

source

pub fn is_resident(&self) -> bool

Returns true if this is a resident attribute, i.e. one where its value is part of the attribute structure.

source

pub fn name(&self) -> Result<U16StrLe<'f>>

Gets the name of this NTFS Attribute (if any) and returns it wrapped in a U16StrLe.

Note that most NTFS attributes have no name and are distinguished by their types. Use NtfsAttribute::ty to get the attribute type.

source

pub fn name_length(&self) -> usize

Returns the length of the name of this NTFS Attribute, in bytes.

An attribute name has a maximum length of 255 UTF-16 code points (510 bytes). It is always part of the attribute itself and hence also of the length returned by NtfsAttribute::attribute_length.

source

pub fn position(&self) -> NtfsPosition

Returns the absolute position of this NTFS Attribute within the filesystem, in bytes.

source

pub fn resident_structured_value<S>(&self) -> Result<S>where S: NtfsStructuredValueFromResidentAttributeValue<'n, 'f>,

Attempts to parse the value data as the given resident structured value type and returns that.

This is a fast path for attributes that are always resident. It doesn’t need a reference to the filesystem reader.

This function first checks that the attribute is of the required type for that structured value and if it’s a resident attribute. It returns with an error if that is not the case. It also returns an error for any parsing problem.

source

pub fn structured_value<T, S>(&self, fs: &mut T) -> Result<S>where T: Read + Seek, S: NtfsStructuredValue<'n, 'f>,

Attempts to parse the value data as the given structured value type and returns that.

This function first checks that the attribute is of the required type for that structured value. It returns with an error if that is not the case. It also returns an error for any parsing problem.

source

pub fn ty(&self) -> Result<NtfsAttributeType>

Returns the type of this NTFS Attribute, or NtfsError::UnsupportedAttributeType if it’s an unknown type.

source

pub fn value<T>(&self, fs: &mut T) -> Result<NtfsAttributeValue<'n, 'f>>where T: Read + Seek,

Returns an NtfsAttributeValue structure to read the value of this NTFS Attribute.

source

pub fn value_length(&self) -> u64

Returns the length of the value data of this NTFS Attribute, in bytes.

Trait Implementations§

source§

impl<'n, 'f> Clone for NtfsAttribute<'n, 'f>

source§

fn clone(&self) -> NtfsAttribute<'n, 'f>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'n, 'f> Debug for NtfsAttribute<'n, 'f>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'n, 'f> RefUnwindSafe for NtfsAttribute<'n, 'f>

§

impl<'n, 'f> Send for NtfsAttribute<'n, 'f>

§

impl<'n, 'f> Sync for NtfsAttribute<'n, 'f>

§

impl<'n, 'f> Unpin for NtfsAttribute<'n, 'f>

§

impl<'n, 'f> UnwindSafe for NtfsAttribute<'n, 'f>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.