[][src]Trait haiku::storage::AttributeExt

pub trait AttributeExt {
    fn iter_attributes(&self) -> Result<AttributeIterator>;
fn find_attribute(&self, name: &str) -> Result<AttributeDescriptor>;
fn read_attribute_raw(
        &self,
        name: &str,
        raw_type: type_code,
        pos: off_t,
        size: i64
    ) -> Result<Vec<u8>>;
fn write_attribute_raw(
        &self,
        name: &str,
        raw_type: type_code,
        pos: off_t,
        buffer: &[u8]
    ) -> Result<()>;
fn remove_attribute(&self, name: &str) -> Result<()>; fn read_attribute<T: Flattenable<T>>(
        &self,
        attribute: &AttributeDescriptor
    ) -> Result<T> { ... }
fn write_attribute<T: Flattenable<T>>(
        &self,
        name: &str,
        value: &T
    ) -> Result<()> { ... } }

The AttributeExt trait allows for reading attributes on file system objects

Implementors of this attribute allow you to read file (and directory) attributes that are implemented for Haiku's native BFS. The trait is implemented for both File and Path objects.

Required methods

fn iter_attributes(&self) -> Result<AttributeIterator>

The attribute iterator returns an iterator over all the attributes.

fn find_attribute(&self, name: &str) -> Result<AttributeDescriptor>

Find an attribute by name

If the attribute cannot be found, an error will be returned.

fn read_attribute_raw(
    &self,
    name: &str,
    raw_type: type_code,
    pos: off_t,
    size: i64
) -> Result<Vec<u8>>

Read an attribute as a vector of bytes

This method is the low level implementation of the read_attribute method, that is available to read the contents of an attribute into any type that implements the Flattenable interface. It is advised to use the higher level implementation if you know which Rust type you want to use.

Note that when you implement this trait for your object, that it is valid to call this method with size 0. If that's the case, the caller expects to get the whole attribute, possibly offset by pos.

fn write_attribute_raw(
    &self,
    name: &str,
    raw_type: type_code,
    pos: off_t,
    buffer: &[u8]
) -> Result<()>

Write an attribute from a slice of bytes

This method is the low level implementation of the write_attribute method, that is available to write any type that implements the Flattenable interface as a file system attribute.

Note that this method does not do any check if the data you are writing is valid for the type you are trying to store. Therefore it is advisable to use the higher level write_attribute method.

fn remove_attribute(&self, name: &str) -> Result<()>

Remove the attribute with the given name

Loading content...

Provided methods

fn read_attribute<T: Flattenable<T>>(
    &self,
    attribute: &AttributeDescriptor
) -> Result<T>

Read an attribute and return a Rust object

This method reads the attribute and returns it in the type T. Please note that you should make sure that the type T matches the type in the AttributeDescriptor. The type T should implement the Flattenable trait.

fn write_attribute<T: Flattenable<T>>(
    &self,
    name: &str,
    value: &T
) -> Result<()>

Write an object as a file system attribute

This method writes a copy of any object that implements the Flattenable trait to the file system.

Loading content...

Implementations on Foreign Types

impl AttributeExt for File[src]

fn read_attribute<T: Flattenable<T>>(
    &self,
    attribute: &AttributeDescriptor
) -> Result<T>
[src]

fn write_attribute<T: Flattenable<T>>(
    &self,
    name: &str,
    value: &T
) -> Result<()>
[src]

impl AttributeExt for Path[src]

fn read_attribute<T: Flattenable<T>>(
    &self,
    attribute: &AttributeDescriptor
) -> Result<T>
[src]

fn write_attribute<T: Flattenable<T>>(
    &self,
    name: &str,
    value: &T
) -> Result<()>
[src]

Loading content...

Implementors

Loading content...