Struct LazyTree

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

Fields§

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

Implementations§

Source§

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

Source

pub fn decrypt( &mut self, account: &Account, id: &Uuid, public_key_cache: &mut LookupTable<Owner, String>, ) -> SharedResult<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, account: &Account, ids: I, public_key_cache: &mut LookupTable<Owner, String>, skip_invisible: bool, ) -> SharedResult<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 create_op( &mut self, id: Uuid, key: AESKey, parent: &Uuid, name: &str, file_type: FileType, account: &Account, ) -> SharedResult<(SignedFile, Uuid)>

Source

pub fn rename_op( &mut self, id: &Uuid, name: &str, account: &Account, ) -> SharedResult<SignedFile>

Source

pub fn move_op( &mut self, id: &Uuid, new_parent: &Uuid, account: &Account, ) -> SharedResult<Vec<SignedFile>>

Source

pub fn delete_op( &self, id: &Uuid, account: &Account, ) -> SharedResult<SignedFile>

Source

pub fn add_share_op( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, account: &Account, ) -> SharedResult<SignedFile>

Source

pub fn delete_share_op( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, account: &Account, ) -> SharedResult<Vec<SignedFile>>

Source

pub fn read_document( &mut self, d: &impl DocumentService, id: &Uuid, account: &Account, ) -> SharedResult<DecryptedDocument>

Source

pub fn update_document_op( &mut self, id: &Uuid, document: &[u8], account: &Account, ) -> SharedResult<(SignedFile, EncryptedDocument)>

Source§

impl<Base, Local, Staged> LazyTree<Staged>
where Staged: StagedTreeLike<Base = Base, Staged = Local, F = SignedFile> + 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, account: &Account, ) -> SharedResult<Uuid>

Source

pub fn create( &mut self, id: Uuid, key: AESKey, parent: &Uuid, name: &str, file_type: FileType, account: &Account, ) -> SharedResult<Uuid>

Source

pub fn rename_unvalidated( &mut self, id: &Uuid, name: &str, account: &Account, ) -> SharedResult<()>

Source

pub fn rename( &mut self, id: &Uuid, name: &str, account: &Account, ) -> SharedResult<()>

Source

pub fn move_unvalidated( &mut self, id: &Uuid, new_parent: &Uuid, account: &Account, ) -> SharedResult<()>

Source

pub fn move_file( &mut self, id: &Uuid, new_parent: &Uuid, account: &Account, ) -> SharedResult<()>

Source

pub fn delete_unvalidated( &mut self, id: &Uuid, account: &Account, ) -> SharedResult<()>

Source

pub fn delete(&mut self, id: &Uuid, account: &Account) -> SharedResult<()>

Source

pub fn add_share_unvalidated( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, account: &Account, ) -> SharedResult<()>

Source

pub fn add_share( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, account: &Account, ) -> SharedResult<()>

Source

pub fn delete_share_unvalidated( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, account: &Account, ) -> SharedResult<()>

Source

pub fn delete_share( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, account: &Account, ) -> SharedResult<()>

Source

pub fn update_document_unvalidated( &mut self, id: &Uuid, document: &[u8], account: &Account, ) -> SharedResult<EncryptedDocument>

Source

pub fn update_document( &mut self, id: &Uuid, document: &[u8], account: &Account, ) -> SharedResult<EncryptedDocument>

Source

pub fn delete_unreferenced_file_versions( &self, docs: &impl DocumentService, ) -> SharedResult<()>

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, ) -> SharedResult<Option<UserAccessMode>>

Source

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

Source

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

Source

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

Source

pub fn decrypt_key( &mut self, id: &Uuid, account: &Account, ) -> SharedResult<AESKey>

Source

pub fn name(&mut self, id: &Uuid, account: &Account) -> SharedResult<String>

Source

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

Source

pub fn children(&mut self, id: &Uuid) -> SharedResult<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) -> SharedResult<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) -> SharedResult<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 decrypt_document( &mut self, id: &Uuid, encrypted: &EncryptedDocument, account: &Account, ) -> SharedResult<DecryptedDocument>

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, account: &Account, ) -> SharedResult<()>

Source§

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

Source

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

Source

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

Source

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

Source§

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

Source

pub fn promote(self) -> SharedResult<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<Base, Local> LazyTree<StagedTree<Base, Local>>
where Base: TreeLike<F = SignedFile>, Local: TreeLike<F = Base::F>,

Source

pub fn path_to_id( &mut self, path: &str, root: &Uuid, account: &Account, ) -> SharedResult<Uuid>

Source

pub fn id_to_path( &mut self, id: &Uuid, account: &Account, ) -> SharedResult<String>

Source

pub fn list_paths( &mut self, filter: Option<Filter>, account: &Account, ) -> SharedResult<Vec<String>>

Source§

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

Source

pub fn create_at_path( &mut self, path: &str, root: &Uuid, account: &Account, pub_key: &PublicKey, ) -> SharedResult<Uuid>

Source§

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

Source

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

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

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: 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) -> HashSet<&Uuid>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn owned_ids(&self) -> HashSet<Uuid>

Source§

fn all_files(&self) -> SharedResult<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§

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

Source§

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

Source§

type Output = T

Should always be Self
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.
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