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_namestates. - 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>
impl<'a> DirTreeRef<'a>
Sourcepub fn parse(data: &'a [u8]) -> Result<DirTreeRef<'a>>
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.
Sourcepub fn files(
&self,
) -> impl Iterator<Item = Result<(&'a str, Checksum)>> + use<'a>
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.
Sourcepub fn dirs(
&self,
) -> impl Iterator<Item = Result<(&'a str, Checksum, Checksum)>> + use<'a>
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.
Sourcepub fn to_owned(&self) -> Result<DirTree>
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::Gvariantif the framing of an entry is not in normal form.Error::InvalidDirTreeif an entry fails a check. These are the reasons:- a reason of
DirTree::check_nameif 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
- a reason of