Skip to main content

XattrState

Struct XattrState 

Source
pub struct XattrState { /* private fields */ }
Expand description

Tracks which extended attributes go inline (in the inode’s extra space) versus in a separate xattr block.

Implementations§

Source§

impl XattrState

Source

pub fn new(inode: u32, inode_capacity: u32, block_capacity: u32) -> Self

Create a new xattr state tracker for the given inode.

Source

pub fn add(&mut self, attr: ExtendedAttribute) -> Result<(), FormatError>

Add an attribute. It is placed inline if there is room; otherwise it goes into the block area. Returns an error if neither has enough space.

Source

pub fn has_inline(&self) -> bool

Whether any inline xattrs have been recorded.

Source

pub fn has_block(&self) -> bool

Whether any block xattrs have been recorded.

Source

pub fn write_inline(&self) -> Result<Vec<u8>, FormatError>

Serialize the inline xattrs into a buffer suitable for the inode’s inline xattr area.

The returned buffer is exactly inode_capacity bytes. Layout:

  • 4-byte magic (XATTR_HEADER_MAGIC)
  • Entries packed from the front (header + name + padding)
  • Values packed from the back (aligned to 4 bytes)
Source

pub fn write_block(&self) -> Result<Vec<u8>, FormatError>

Serialize the block xattrs into a full block-sized buffer.

Layout:

  • 32-byte header (magic + refcount=1 + blocks=1 + 20 zero bytes)
  • Entries sorted by (index, name_len, name), packed from the front
  • Values packed from the back

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.