Skip to main content

FolderList

Struct FolderList 

Source
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

Source

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.

Source

pub fn decode(bytes: &[u8]) -> Result<Self>

Reads a whole list: its entries, one after another.

Source

pub fn encode(&self) -> Vec<u8> ⓘ

Source

pub fn entries(&self) -> &[Entry]

Examples found in repository?
examples/roundtrip.rs (line 206)
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}
Source

pub fn count(&self) -> u64

How many entries the folder has.

Source

pub fn size(&self) -> u64

How many bytes of file content are under the folder.

Source

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.

Source

pub fn target(&self) -> Target

Source

pub fn encoded_len(&self) -> u64

How many bytes the list takes.

Source

pub fn get(&self, name: &str) -> Option<&Entry>

The entry with this name.

Source

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.

Source

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.

Source

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

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 Debug for FolderList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FolderList

Source§

impl PartialEq for FolderList

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FolderList

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.