Skip to main content

DirTreeRef

Struct DirTreeRef 

Source
pub struct DirTreeRef<'a> { /* private fields */ }
Expand description

A borrowed view of a serialized dirtree object.

A full walk of a dirtree borrows the object buffer for the whole walk and does not allocate.

§Checks

parse checks the container framing only. The iterators files and dirs check each entry when they visit it, so they yield Result. These are the checks:

  • The name is one path component, as DirTree::check_name states.
  • Each checksum is 32 bytes long.
  • The name sorts strictly after the previous name of the same list, in byte-wise order.

After an error, an iterator is exhausted and returns None.

§Names in both lists

The view checks each list alone, because a check across the two lists needs an allocation. DirTree::parse refuses an object with a name in both lists.

The ostree command reads such an object in the same way as the view. ostree fsck accepts it, and ostree ls lists both entries. The ostree command aborts only when it resolves the name as a directory.

Implementations§

Source§

impl<'a> DirTreeRef<'a>

Source

pub fn parse(data: &'a [u8]) -> Result<DirTreeRef<'a>>

Parses a serialized dirtree object into a borrowed view.

data must cover exactly one serialized dirtree object. The parse checks the container framing only. The iterators check the entries, as the checks state.

§Errors

Error::Gvariant if the framing of the tuple or of one of its two arrays is not in normal form.

Source

pub fn files( &self, ) -> impl Iterator<Item = Result<(&'a str, Checksum)>> + use<'a>

Returns an iterator over the file entries.

The iterator checks each entry when it visits it, as the checks state. An item is an error if the entry fails a check or if its framing is not in normal form.

Source

pub fn dirs( &self, ) -> impl Iterator<Item = Result<(&'a str, Checksum, Checksum)>> + use<'a>

Returns an iterator over the directory entries.

The iterator checks each entry when it visits it, as the checks state. An item is an error if the entry fails a check or if its framing is not in normal form.

Source

pub fn to_owned(&self) -> Result<DirTree>

Collects the entries into an owned DirTree.

The result can hold a name in both lists, because this function does no check across the two lists. DirTree::parse adds that check.

§Errors
  • Error::Gvariant if the framing of an entry is not in normal form.
  • Error::InvalidDirTree if an entry fails a check. These are the reasons:
    • a reason of DirTree::check_name if a name is not one path component
    • "entry names are not sorted" if a name does not sort strictly after the previous name of its list
    • "entry checksum is not 32 bytes" if a checksum has a different length

Trait Implementations§

Source§

impl<'a> Clone for DirTreeRef<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for DirTreeRef<'a>

Auto Trait Implementations§

§

impl<'a> Forget for DirTreeRef<'a>

§

impl<'a> Freeze for DirTreeRef<'a>
where &'a [u8]: Freeze, PhantomData<fn() -> (&'a str, &'a [u8])>: Freeze, PhantomData<fn() -> (&'a str, &'a [u8], &'a [u8])>: Freeze,

§

impl<'a> Move for DirTreeRef<'a>

§

impl<'a> RefUnwindSafe for DirTreeRef<'a>

§

impl<'a> Send for DirTreeRef<'a>
where &'a [u8]: Send,

§

impl<'a> Sync for DirTreeRef<'a>

§

impl<'a> Unpin for DirTreeRef<'a>
where &'a [u8]: Unpin,

§

impl<'a> UnsafeUnpin for DirTreeRef<'a>
where &'a [u8]: UnsafeUnpin, PhantomData<fn() -> (&'a str, &'a [u8])>: UnsafeUnpin, PhantomData<fn() -> (&'a str, &'a [u8], &'a [u8])>: UnsafeUnpin,

§

impl<'a> UnwindSafe for DirTreeRef<'a>
where &'a [u8]: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.