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
impl XattrState
Sourcepub fn new(inode: u32, inode_capacity: u32, block_capacity: u32) -> Self
pub fn new(inode: u32, inode_capacity: u32, block_capacity: u32) -> Self
Create a new xattr state tracker for the given inode.
Sourcepub fn add(&mut self, attr: ExtendedAttribute) -> Result<(), FormatError>
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.
Sourcepub fn has_inline(&self) -> bool
pub fn has_inline(&self) -> bool
Whether any inline xattrs have been recorded.
Sourcepub fn write_inline(&self) -> Result<Vec<u8>, FormatError>
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)
Sourcepub fn write_block(&self) -> Result<Vec<u8>, FormatError>
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§
impl Freeze for XattrState
impl RefUnwindSafe for XattrState
impl Send for XattrState
impl Sync for XattrState
impl Unpin for XattrState
impl UnsafeUnpin for XattrState
impl UnwindSafe for XattrState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more