pub struct FolderList { /* private fields */ }Expand description
A folder: the list of its entries, sorted by name, with no name twice.
Implementations§
Source§impl FolderList
impl FolderList
Sourcepub fn new(entries: Vec<Entry>) -> Result<Self>
pub fn new(entries: Vec<Entry>) -> Result<Self>
The folder with these entries. They must be in the order of their names’ bytes, with no name twice. No entries is the empty folder.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self>
pub fn decode(bytes: &[u8]) -> Result<Self>
Reads a whole list: its entries, one after another.
pub fn encode(&self) -> Vec<u8> ⓘ
Sourcepub fn entries(&self) -> &[Entry]
pub fn entries(&self) -> &[Entry]
Examples found in repository?
194fn largest_file(store: &dyn Store, top: Target) -> Result<Option<Target>> {
195 let mut largest: Option<Target> = None;
196 let mut seen = std::collections::HashSet::new();
197 let mut pending = vec![top];
198 while let Some(target) = pending.pop() {
199 match target.kind {
200 Kind::File if largest.is_none_or(|file| file.size < target.size) => {
201 largest = Some(target);
202 }
203 Kind::File => {}
204 Kind::Folder if seen.insert(target.hash) => {
205 let list = folder_of(store, &target)?;
206 pending.extend(list.entries().iter().map(|entry| entry.target()));
207 }
208 Kind::Folder => {}
209 }
210 }
211 Ok(largest)
212}Sourcepub fn hash(&self) -> &Hash
pub fn hash(&self) -> &Hash
The folder’s hash. It covers every entry: its name, its kind, its size, its hash and its extra data. It does not cover a name for the folder itself.
pub fn target(&self) -> Target
Sourcepub fn encoded_len(&self) -> u64
pub fn encoded_len(&self) -> u64
How many bytes the list takes.
Sourcepub fn place_of(&self, name: &str) -> Option<u64>
pub fn place_of(&self, name: &str) -> Option<u64>
The one place where name can be: that of the last entry whose name
does not sort after it, or the first place. An empty folder has none.
Sourcepub fn open(&self, start: u64, end: u64) -> Result<FolderBranch>
pub fn open(&self, start: u64, end: u64) -> Result<FolderBranch>
Shows entries start up to, not including, end. This hashes the
whole list each time: keep an OpenFolder to show many parts.
Sourcepub fn open_name(&self, name: &str) -> Result<FolderBranch>
pub fn open_name(&self, name: &str) -> Result<FolderBranch>
Shows the entry at the one place where name can be. It answers
whether the folder has the name, whichever way the answer falls.
Trait Implementations§
Source§impl Clone for FolderList
impl Clone for FolderList
Source§impl Debug for FolderList
impl Debug for FolderList
impl Eq for FolderList
Source§impl PartialEq for FolderList
impl PartialEq for FolderList
impl StructuralPartialEq for FolderList
Auto Trait Implementations§
impl Forget for FolderList
impl Freeze for FolderList
impl Move for FolderList
impl RefUnwindSafe for FolderList
impl Send for FolderList
impl Sync for FolderList
impl Unpin for FolderList
impl UnsafeUnpin for FolderList
impl UnwindSafe for FolderList
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more