ouisync

Struct JointDirectory

Source
pub struct JointDirectory { /* private fields */ }
Expand description

Unified view over multiple concurrent versions of a directory.

Implementations§

Source§

impl JointDirectory

Source

pub fn new<I>(local_branch: Option<Branch>, versions: I) -> Self
where 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.

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

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.

Source

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 the name.
  • 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.
Source

pub fn lookup_version( &self, name: &str, branch_id: &PublicKey, ) -> Result<FileRef<'_>>

Looks up a specific version of a file.

Source

pub fn len(&self) -> u64

Length of the directory in bytes. If there are multiple versions, returns the sum of their lengths.

Source

pub fn has_local_version(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> JointDirectory

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for JointDirectory

Source§

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

Formats the value using the given formatter. Read more

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Value for T
where T: Debug + Any + Send + 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T