pub struct JointDirectory { /* private fields */ }
Expand description
Unified view over multiple concurrent versions of a directory.
Implementations§
Source§impl JointDirectory
impl JointDirectory
Sourcepub fn new<I>(local_branch: Option<Branch>, versions: I) -> Selfwhere
I: IntoIterator<Item = Directory>,
pub fn new<I>(local_branch: Option<Branch>, versions: I) -> Selfwhere
I: IntoIterator<Item = Directory>,
Creates a new JointDirectory
over the specified directory versions.
Note: if local_branch
is None
then the created joint directory is read-only.
pub fn is_empty(&self) -> bool
Sourcepub fn entries(&self) -> impl Iterator<Item = JointEntryRef<'_>>
pub fn entries(&self) -> impl Iterator<Item = JointEntryRef<'_>>
Returns iterator over the entries of this directory. Multiple concurrent versions of the
same file are returned as separate JointEntryRef::File
entries. Multiple concurrent
versions of the same directory are returned as a single JointEntryRef::Directory
entry.
Sourcepub fn lookup<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = JointEntryRef<'a>> + 'a
pub fn lookup<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = JointEntryRef<'a>> + 'a
Returns all versions of an entry with the given name. Concurrent file versions are returned
separately but concurrent directory versions are merged into a single JointDirectory
.
Sourcepub fn lookup_unique<'a>(&'a self, name: &'a str) -> Result<JointEntryRef<'a>>
pub fn lookup_unique<'a>(&'a self, name: &'a str) -> Result<JointEntryRef<'a>>
Looks up single entry with the specified name if it is unique.
- If there is only one version of a entry with the specified name, it is returned.
- If there are multiple versions and all of them are files, an
AmbiguousEntry
error is returned. To lookup a single version, include a disambiguator in thename
. - If there are multiple versiond and all of them are directories, they are merged into a
single
JointEntryRef::Directory
and returned. - Finally, if there are both files and directories, only the directories are retured (merged
into a
JointEntryRef::Directory
) and the files are discarded. This is so it’s possible to unambiguously lookup a directory even in the presence of conflicting files.
Sourcepub fn lookup_version(
&self,
name: &str,
branch_id: &PublicKey,
) -> Result<FileRef<'_>>
pub fn lookup_version( &self, name: &str, branch_id: &PublicKey, ) -> Result<FileRef<'_>>
Looks up a specific version of a file.
Sourcepub fn len(&self) -> u64
pub fn len(&self) -> u64
Length of the directory in bytes. If there are multiple versions, returns the sum of their lengths.
pub fn has_local_version(&self) -> bool
Sourcepub async fn cd(&self, path: impl AsRef<Utf8Path>) -> Result<Self>
pub async fn cd(&self, path: impl AsRef<Utf8Path>) -> Result<Self>
Descends into an arbitrarily nested subdirectory of this directory at the specified path. Note: non-normalized paths (i.e. containing “..”) or Windows-style drive prefixes (e.g. “C:”) are not supported.
Sourcepub async fn remove_entry(&mut self, name: &str) -> Result<()>
pub async fn remove_entry(&mut self, name: &str) -> Result<()>
Removes the specified entry from this directory. If the entry is a subdirectory, it has to be empty. Use Self::remove_entry_recursively to remove non-empty subdirectories.
Sourcepub async fn remove_entry_recursively(&mut self, name: &str) -> Result<()>
pub async fn remove_entry_recursively(&mut self, name: &str) -> Result<()>
Removes the specified entry from this directory, including all its content if it is a subdirectory.
Sourcepub fn merge<'life_self, 'async_recursion>(
&'life_self mut self,
) -> Pin<Box<dyn Future<Output = Result<Directory>> + Send + 'async_recursion>>where
'life_self: 'async_recursion,
pub fn merge<'life_self, 'async_recursion>(
&'life_self mut self,
) -> Pin<Box<dyn Future<Output = Result<Directory>> + Send + 'async_recursion>>where
'life_self: 'async_recursion,
Merge all versions of this JointDirectory
into a single Directory
.
In the presence of conflicts (multiple concurrent versions of the same file) this function
still proceeds as far as it can, but the conflicting files remain unmerged. It signals this
by returning Error::AmbiguousEntry
.
Trait Implementations§
Source§impl Clone for JointDirectory
impl Clone for JointDirectory
Source§fn clone(&self) -> JointDirectory
fn clone(&self) -> JointDirectory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for JointDirectory
impl !RefUnwindSafe for JointDirectory
impl Send for JointDirectory
impl Sync for JointDirectory
impl Unpin for JointDirectory
impl !UnwindSafe for JointDirectory
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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