LazyTree

Struct LazyTree 

Source
pub struct LazyTree<T: TreeLike> {
    pub tree: T,
    pub name: HashMap<Uuid, String>,
    pub implicit_deleted: HashMap<Uuid, bool>,
    pub linked_by: HashMap<Uuid, Uuid>,
    pub children: HashMap<Uuid, HashSet<Uuid>>,
}

Fields§

§tree: T§name: HashMap<Uuid, String>§implicit_deleted: HashMap<Uuid, bool>§linked_by: HashMap<Uuid, Uuid>§children: HashMap<Uuid, HashSet<Uuid>>

Implementations§

Source§

impl<T> LazyTree<T>
where T: TreeLike<F = SignedMeta>,

Source

pub fn decrypt( &mut self, keychain: &Keychain, id: &Uuid, public_key_cache: &LookupTable<Owner, String>, ) -> LbResult<File>

convert FileMetadata into File. fields have been decrypted, public keys replaced with usernames, deleted files filtered out, etc.

Source

pub fn decrypt_all<I>( &mut self, keychain: &Keychain, ids: I, public_key_cache: &LookupTable<Owner, String>, skip_invisible: bool, ) -> LbResult<Vec<File>>
where I: Iterator<Item = Uuid>,

convert FileMetadata into File. fields have been decrypted, public keys replaced with usernames, deleted files filtered out, etc.

Source

pub fn is_invisible_id(&mut self, id: Uuid) -> LbResult<bool>

Source

pub fn create_op( &mut self, id: Uuid, key: AESKey, parent: &Uuid, name: &str, file_type: FileType, keychain: &Keychain, ) -> LbResult<(SignedMeta, Uuid)>

Source

pub fn rename_op( &mut self, id: &Uuid, name: &str, keychain: &Keychain, ) -> LbResult<SignedMeta>

Source

pub fn move_op( &mut self, id: &Uuid, new_parent: &Uuid, keychain: &Keychain, ) -> LbResult<Vec<SignedMeta>>

Source

pub fn delete_op(&self, id: &Uuid, keychain: &Keychain) -> LbResult<SignedMeta>

Source

pub fn add_share_op( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, keychain: &Keychain, ) -> LbResult<SignedMeta>

Source

pub fn delete_share_op( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, keychain: &Keychain, ) -> LbResult<Vec<SignedMeta>>

Source

pub fn decrypt_document( &mut self, id: &Uuid, doc: &EncryptedDocument, keychain: &Keychain, ) -> LbResult<DecryptedDocument>

Source

pub fn update_document_op( &mut self, id: &Uuid, document: &[u8], keychain: &Keychain, ) -> LbResult<(SignedMeta, EncryptedDocument)>

Source§

impl<Base, Local, Staged> LazyTree<Staged>
where Staged: StagedTreeLike<Base = Base, Staged = Local, F = SignedMeta> + TreeLikeMut, Base: TreeLike<F = Staged::F>, Local: TreeLikeMut<F = Staged::F>,

Source

pub fn create_unvalidated( &mut self, id: Uuid, key: AESKey, parent: &Uuid, name: &str, file_type: FileType, keychain: &Keychain, ) -> LbResult<Uuid>

Source

pub fn create( &mut self, id: Uuid, key: AESKey, parent: &Uuid, name: &str, file_type: FileType, keychain: &Keychain, ) -> LbResult<Uuid>

Source

pub fn rename_unvalidated( &mut self, id: &Uuid, name: &str, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn rename( &mut self, id: &Uuid, name: &str, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn move_unvalidated( &mut self, id: &Uuid, new_parent: &Uuid, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn move_file( &mut self, id: &Uuid, new_parent: &Uuid, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn delete_unvalidated( &mut self, id: &Uuid, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn delete(&mut self, id: &Uuid, keychain: &Keychain) -> LbResult<()>

Source

pub fn add_share_unvalidated( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn add_share( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn delete_share_unvalidated( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn delete_share( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, keychain: &Keychain, ) -> LbResult<()>

Source

pub fn update_document_unvalidated( &mut self, id: &Uuid, document: &[u8], keychain: &Keychain, ) -> LbResult<EncryptedDocument>

Source

pub fn update_document( &mut self, id: &Uuid, document: &[u8], keychain: &Keychain, ) -> LbResult<EncryptedDocument>

Source§

impl<T: TreeLike> LazyTree<T>

Source

pub fn new(tree: T) -> Self

Source§

impl<T: TreeLike> LazyTree<T>

Source

pub fn access_mode( &self, owner: Owner, id: &Uuid, ) -> LbResult<Option<UserAccessMode>>

Source

pub fn in_pending_share(&mut self, id: &Uuid) -> LbResult<bool>

Source

pub fn all_children(&mut self) -> LbResult<&HashMap<Uuid, HashSet<Uuid>>>

Source

pub fn calculate_deleted(&mut self, id: &Uuid) -> LbResult<bool>

Source

pub fn decrypt_key( &mut self, id: &Uuid, keychain: &Keychain, ) -> LbResult<AESKey>

Source

pub fn name(&mut self, id: &Uuid, keychain: &Keychain) -> LbResult<String>

Source

pub fn linked_by(&mut self, id: &Uuid) -> LbResult<Option<Uuid>>

Source

pub fn children(&mut self, id: &Uuid) -> LbResult<HashSet<Uuid>>

Returns ids of files whose parent is the argument. Does not include the argument. TODO could consider returning a reference to the underlying cached value

Source

pub fn descendants(&mut self, id: &Uuid) -> LbResult<HashSet<Uuid>>

Returns ids of files for which the argument is an ancestor—the files’ children, recursively. Does not include the argument. This function tolerates cycles.

Source

pub fn ancestors(&self, id: &Uuid) -> LbResult<HashSet<Uuid>>

Returns ids of files for which the argument is a descendent—the files’ parent, recursively. Does not include the argument. This function tolerates cycles.

Source

pub fn pending_roots(&mut self, keychain: &Keychain) -> LbResult<Vec<Uuid>>

Source

pub fn non_deleted_pending_files( &mut self, keychain: &Keychain, ) -> LbResult<Vec<Uuid>>

Source

pub fn stage<T2: TreeLikeMut<F = T::F>>( self, staged: T2, ) -> LazyTree<StagedTree<T, T2>>

Source

pub fn stage_removals( self, removed: HashSet<Uuid>, ) -> LazyTree<StagedTree<T, Option<T::F>>>

Source

pub fn assert_names_decryptable(&mut self, keychain: &Keychain) -> LbResult<()>

Source§

impl<T> LazyTree<T>
where T: TreeLikeMut,

Source

pub fn stage_and_promote<S: TreeLikeMut<F = T::F>>( &mut self, staged: S, ) -> LbResult<()>

Source

pub fn stage_validate_and_promote<S: TreeLikeMut<F = T::F>>( &mut self, staged: S, owner: Owner, ) -> LbResult<()>

Source

pub fn stage_removals_and_promote( &mut self, removed: HashSet<Uuid>, ) -> LbResult<()>

Source§

impl<Base, Staged> LazyTree<StagedTree<Base, Staged>>
where Base: TreeLikeMut, Staged: TreeLikeMut<F = Base::F>,

Source

pub fn promote(self) -> LbResult<LazyTree<Base>>

Source§

impl<Base, Staged> LazyTree<StagedTree<Base, Staged>>
where Base: TreeLike, Staged: TreeLikeMut<F = Base::F>,

Source

pub fn unstage(self) -> (LazyTree<Base>, Staged)

Source§

impl<T> LazyTree<T>
where T: TreeLike<F = SignedMeta>,

Source

pub fn path_to_id( &mut self, path: &str, root: &Uuid, keychain: &Keychain, ) -> LbResult<Uuid>

Source

pub fn id_to_path(&mut self, id: &Uuid, keychain: &Keychain) -> LbResult<String>

Source

pub fn list_paths( &mut self, filter: Option<Filter>, keychain: &Keychain, ) -> LbResult<Vec<(Uuid, String)>>

Source§

impl<Base, Local> LazyTree<StagedTree<Base, Local>>
where Base: TreeLike<F = SignedMeta>, Local: TreeLikeMut<F = Base::F>,

Source

pub fn create_at_path( &mut self, path: &str, root: &Uuid, keychain: &Keychain, ) -> LbResult<Uuid>

Source§

impl<'a> LazyTree<ServerTree<'a>>

Source

pub fn stage_diff( self, changes: Vec<FileDiff<SignedFile>>, ) -> LbResult<LazyStaged1<ServerTree<'a>, Vec<ServerMeta>>>

Validates a diff prior to staging it. Performs individual validations, then validations that require a tree

Source

pub fn stage_diff_v2( self, changes: Vec<FileDiff<SignedMeta>>, ) -> LbResult<LazyStaged1<ServerTree<'a>, Vec<ServerMeta>>>

Source§

impl<T, Base, Local> LazyTree<T>
where T: StagedTreeLike<Base = Base, Staged = Local>, Base: TreeLike<F = T::F>, Local: TreeLike<F = T::F>,

Trait Implementations§

Source§

impl<T: Clone + TreeLike> Clone for LazyTree<T>

Source§

fn clone(&self) -> LazyTree<T>

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + TreeLike> Debug for LazyTree<T>

Source§

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

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

impl<T: TreeLike> TreeLike for LazyTree<T>

Source§

type F = <T as TreeLike>::F

Source§

fn ids(&self) -> Vec<Uuid>

Source§

fn maybe_find(&self, id: &Uuid) -> Option<&Self::F>

Source§

fn find(&self, id: &Uuid) -> LbResult<&Self::F>

Source§

fn maybe_find_parent<F2: FileLike>(&self, file: &F2) -> Option<&Self::F>

Source§

fn find_parent<F2: FileLike>(&self, file: &F2) -> LbResult<&Self::F>

Source§

fn all_files(&self) -> LbResult<Vec<&Self::F>>

Source§

fn stage<Staged>(&self, staged: Staged) -> StagedTree<&Self, Staged>
where Staged: TreeLike<F = Self::F>, Self: Sized,

Source§

fn to_staged<Staged>(self, staged: Staged) -> StagedTree<Self, Staged>
where Staged: TreeLike<F = Self::F>, Self: Sized,

Source§

fn as_lazy(&self) -> LazyTree<&Self>

Source§

fn to_lazy(self) -> LazyTree<Self>

Auto Trait Implementations§

§

impl<T> Freeze for LazyTree<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LazyTree<T>
where T: RefUnwindSafe,

§

impl<T> Send for LazyTree<T>
where T: Send,

§

impl<T> Sync for LazyTree<T>
where T: Sync,

§

impl<T> Unpin for LazyTree<T>
where T: Unpin,

§

impl<T> UnwindSafe for LazyTree<T>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

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

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

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
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> Fruit for T
where T: Send + Downcast,