23 releases (7 stable)

1.3.1 Jan 15, 2024
1.2.0 Dec 28, 2023
1.0.1 Jul 29, 2023
1.0.0 Nov 29, 2022
0.1.2 Jul 10, 2015

#22 in Filesystem

Download history 425581/week @ 2023-12-06 407408/week @ 2023-12-13 282050/week @ 2023-12-20 220885/week @ 2023-12-27 372261/week @ 2024-01-03 405539/week @ 2024-01-10 489826/week @ 2024-01-17 477656/week @ 2024-01-24 479217/week @ 2024-01-31 462021/week @ 2024-02-07 473031/week @ 2024-02-14 548753/week @ 2024-02-21 541443/week @ 2024-02-28 538786/week @ 2024-03-06 517025/week @ 2024-03-13 434367/week @ 2024-03-20

2,130,190 downloads per month
Used in 2,020 crates (48 directly)

MIT/Apache

28KB
657 lines

xattr

A small library for setting, getting, and listing extended attributes.

Supported Platforms: Android, Linux, MacOS, FreeBSD, and NetBSD.

API Documentation: https://docs.rs/xattr/latest/xattr/

Unsupported Platforms

This library includes no-op support for unsupported Unix platforms. That is, it will build on all Unix platforms but always fail on unsupported Unix platforms.

  1. You can turn this off by disabling the default unsupported feature. If you do so, this library will fail to compile on unsupported platforms.
  2. Alternatively, you can detect unsupported platforms at runtime by checking the xattr::SUPPORTED_PLATFORM boolean.

lib.rs:

A pure-Rust library to manage extended attributes.

It provides support for manipulating extended attributes (xattrs) on modern Unix filesystems. See the attr(5) manpage for more details.

An extension trait FileExt is provided to directly work with standard File objects and file descriptors.

If the path argument is a symlink, the get/set/list/remove functions operate on the symlink itself. To operate on the symlink target, use the _deref variant of these functions.

let mut xattrs = xattr::list("/").unwrap().peekable();

if xattrs.peek().is_none() {
    println!("no xattr set on root");
    return;
}

println!("Extended attributes:");
for attr in xattrs {
    println!(" - {:?}", attr);
}

Dependencies

~2–12MB
~132K SLoC