Struct lb_rs::LazyTree

source ·
pub struct LazyTree<T>
where T: TreeLike,
{ pub tree: T, pub name: HashMap<Uuid, String>, pub key: HashMap<Uuid, [u8; 32]>, pub implicit_deleted: HashMap<Uuid, bool>, pub children: HashMap<Uuid, HashSet<Uuid>>, }

Fields§

§tree: T§name: HashMap<Uuid, String>§key: HashMap<Uuid, [u8; 32]>§implicit_deleted: HashMap<Uuid, bool>§children: HashMap<Uuid, HashSet<Uuid>>

Implementations§

source§

impl<T> LazyTree<T>

source

pub fn decrypt( &mut self, account: &Account, id: &Uuid, public_key_cache: &mut LookupTable<Owner, String> ) -> Result<File, SharedError>

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 ) -> Result<Vec<File>, SharedError>
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: [u8; 32], parent: &Uuid, name: &str, file_type: FileType, account: &Account ) -> Result<(ECSigned<FileMetadata>, Uuid), SharedError>

source

pub fn rename_op( &mut self, id: &Uuid, name: &str, account: &Account ) -> Result<ECSigned<FileMetadata>, SharedError>

source

pub fn move_op( &mut self, id: &Uuid, new_parent: &Uuid, account: &Account ) -> Result<Vec<ECSigned<FileMetadata>>, SharedError>

source

pub fn delete_op( &self, id: &Uuid, account: &Account ) -> Result<ECSigned<FileMetadata>, SharedError>

source

pub fn add_share_op( &mut self, id: Uuid, sharee: Owner, mode: ShareMode, account: &Account ) -> Result<ECSigned<FileMetadata>, SharedError>

source

pub fn delete_share_op( &mut self, id: &Uuid, maybe_encrypted_for: Option<PublicKey>, account: &Account ) -> Result<Vec<ECSigned<FileMetadata>>, SharedError>

source

pub fn read_document( &mut self, d: &impl DocumentService, id: &Uuid, account: &Account ) -> Result<Vec<u8>, SharedError>

source

pub fn update_document_op( &mut self, id: &Uuid, document: &[u8], account: &Account ) -> Result<(ECSigned<FileMetadata>, AESEncrypted<Vec<u8>>), SharedError>

source§

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

source

pub fn create_unvalidated( &mut self, id: Uuid, key: [u8; 32], parent: &Uuid, name: &str, file_type: FileType, account: &Account ) -> Result<Uuid, SharedError>

source

pub fn create( &mut self, id: Uuid, key: [u8; 32], parent: &Uuid, name: &str, file_type: FileType, account: &Account ) -> Result<Uuid, SharedError>

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn update_document_unvalidated( &mut self, id: &Uuid, document: &[u8], account: &Account ) -> Result<AESEncrypted<Vec<u8>>, SharedError>

source

pub fn update_document( &mut self, id: &Uuid, document: &[u8], account: &Account ) -> Result<AESEncrypted<Vec<u8>>, SharedError>

source

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

source§

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

source

pub fn new(tree: T) -> LazyTree<T>

source§

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

source

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

source

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

source

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

source

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

source

pub fn decrypt_key( &mut self, id: &Uuid, account: &Account ) -> Result<[u8; 32], SharedError>

source

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

source

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

source

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

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) -> Result<HashSet<Uuid>, SharedError>

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) -> Result<HashSet<Uuid>, SharedError>

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: &AESEncrypted<Vec<u8>>, account: &Account ) -> Result<Vec<u8>, SharedError>

source

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

source

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

source

pub fn assert_names_decryptable( &mut self, account: &Account ) -> Result<(), SharedError>

source§

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

source

pub fn stage_and_promote<S>(&mut self, staged: S) -> Result<(), SharedError>
where S: TreeLikeMut<F = <T as TreeLike>::F>,

source

pub fn stage_validate_and_promote<S>( &mut self, staged: S, owner: Owner ) -> Result<(), SharedError>
where S: TreeLikeMut<F = <T as TreeLike>::F>,

source

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

source§

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

source

pub fn promote(self) -> Result<LazyTree<Base>, SharedError>

source§

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

source

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

source§

impl<Base, Local> LazyTree<StagedTree<Base, Local>>
where Base: TreeLike<F = ECSigned<FileMetadata>>, Local: TreeLike<F = <Base as TreeLike>::F>,

source

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

source

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

source

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

source§

impl<Base, Local> LazyTree<StagedTree<Base, Local>>
where Base: TreeLike<F = ECSigned<FileMetadata>>, Local: TreeLikeMut<F = <Base as TreeLike>::F>,

source

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

source§

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

source

pub fn stage_diff( self, changes: Vec<FileDiff<ECSigned<FileMetadata>>> ) -> Result<LazyTree<StagedTree<ServerTree<'a>, Vec<ServerFile>>>, SharedError>

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

source§

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

Trait Implementations§

source§

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

source§

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

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

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

§

type F = <T as TreeLike>::F

source§

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

source§

fn maybe_find(&self, id: &Uuid) -> Option<&<LazyTree<T> as TreeLike>::F>

source§

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

source§

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

source§

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

source§

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

source§

fn all_files(&self) -> Result<Vec<&Self::F>, SharedError>

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

source§

const ALIGN: usize = _

The alignment of pointer.
§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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