pub struct Directory<S: HandleOwner> { /* private fields */ }
Expand description
A directory stores name to child object mappings.
Implementations§
Source§impl<S: HandleOwner> Directory<S>
impl<S: HandleOwner> Directory<S>
pub fn object_id(&self) -> u64
pub fn wrapping_key_id(&self) -> Option<u128>
Sourcepub async fn get_fscrypt_key(&self) -> Result<Option<Key>, Error>
pub async fn get_fscrypt_key(&self) -> Result<Option<Key>, Error>
Retrieves keys from the key manager or unwraps the wrapped keys in the directory’s key record. Returns None if the key is currently unavailable due to the wrapping key being unavailable.
pub fn owner(&self) -> &Arc<S>
pub fn store(&self) -> &ObjectStore
pub fn handle(&self) -> &StoreObjectHandle<S>
pub fn is_deleted(&self) -> bool
pub fn set_deleted(&self)
Sourcepub fn casefold(&self) -> bool
pub fn casefold(&self) -> bool
True if this directory is using casefolding (case-insensitive, normalized unicode filenames)
Sourcepub async fn set_casefold(&self, val: bool) -> Result<(), Error>
pub async fn set_casefold(&self, val: bool) -> Result<(), Error>
Enables/disables casefolding. This can only be done on an empty directory.
pub async fn create( transaction: &mut Transaction<'_>, owner: &Arc<S>, wrapping_key_id: Option<u128>, ) -> Result<Directory<S>, Error>
pub async fn create_with_options( transaction: &mut Transaction<'_>, owner: &Arc<S>, wrapping_key_id: Option<u128>, casefold: bool, ) -> Result<Directory<S>, Error>
pub async fn set_wrapping_key( &self, transaction: &mut Transaction<'_>, id: u128, ) -> Result<Cipher, Error>
pub async fn open(owner: &Arc<S>, object_id: u64) -> Result<Directory<S>, Error>
Sourcepub fn open_unchecked(
owner: Arc<S>,
object_id: u64,
wrapping_key_id: Option<u128>,
casefold: bool,
) -> Self
pub fn open_unchecked( owner: Arc<S>, object_id: u64, wrapping_key_id: Option<u128>, casefold: bool, ) -> Self
Opens a directory. The caller is responsible for ensuring that the object exists and is a directory.
Sourcepub async fn acquire_context_for_replace(
&self,
src: Option<(&Directory<S>, &str)>,
dst: &str,
borrow_metadata_space: bool,
) -> Result<ReplaceContext<'_>, Error>
pub async fn acquire_context_for_replace( &self, src: Option<(&Directory<S>, &str)>, dst: &str, borrow_metadata_space: bool, ) -> Result<ReplaceContext<'_>, Error>
Acquires the transaction with the appropriate locks to replace |dst| with |src.0|/|src.1|. |src| can be None in the case of unlinking |dst| from |self|. Returns the transaction, as well as the ID and type of the child and the src. If the child doesn’t exist, then a transaction is returned with a lock only on the parent and None for the target info so that the transaction can be executed with the confidence that the target doesn’t exist. If the src doesn’t exist (in the case of unlinking), None is return for the source info.
We need to lock |self|, but also the child if it exists. When it is a directory the lock prevents entries being added at the same time. When it is a file needs to be able to decrement the reference count. If src exists, we also need to lock |src.0| and |src.1|. This is to update their timestamps.
Sourcepub async fn lookup(
&self,
name: &str,
) -> Result<Option<(u64, ObjectDescriptor)>, Error>
pub async fn lookup( &self, name: &str, ) -> Result<Option<(u64, ObjectDescriptor)>, Error>
Returns the object ID and descriptor for the given child, or None if not found.
pub async fn create_child_dir( &self, transaction: &mut Transaction<'_>, name: &str, ) -> Result<Directory<S>, Error>
pub async fn add_child_file<'a>( &self, transaction: &mut Transaction<'a>, name: &str, handle: &DataObjectHandle<S>, ) -> Result<(), Error>
pub async fn create_child_file<'a>( &self, transaction: &mut Transaction<'a>, name: &str, ) -> Result<DataObjectHandle<S>, Error>
pub async fn create_child_file_with_options<'a>( &self, transaction: &mut Transaction<'a>, name: &str, options: HandleOptions, ) -> Result<DataObjectHandle<S>, Error>
pub async fn create_child_unnamed_temporary_file<'a>( &self, transaction: &mut Transaction<'a>, ) -> Result<DataObjectHandle<S>, Error>
pub async fn create_symlink( &self, transaction: &mut Transaction<'_>, link: &[u8], name: &str, ) -> Result<u64, Error>
pub async fn add_child_volume( &self, transaction: &mut Transaction<'_>, volume_name: &str, store_object_id: u64, ) -> Result<(), Error>
pub async fn delete_child_volume<'a>( &self, transaction: &mut Transaction<'a>, volume_name: &str, store_object_id: u64, ) -> Result<(), Error>
Sourcepub async fn insert_child<'a>(
&self,
transaction: &mut Transaction<'a>,
name: &str,
object_id: u64,
descriptor: ObjectDescriptor,
) -> Result<(), Error>
pub async fn insert_child<'a>( &self, transaction: &mut Transaction<'a>, name: &str, object_id: u64, descriptor: ObjectDescriptor, ) -> Result<(), Error>
Inserts a child into the directory.
Requires transaction locks on |self|.
Sourcepub async fn update_attributes<'a>(
&self,
transaction: Transaction<'a>,
node_attributes: Option<&MutableNodeAttributes>,
sub_dirs_delta: i64,
change_time: Option<Timestamp>,
) -> Result<(), Error>
pub async fn update_attributes<'a>( &self, transaction: Transaction<'a>, node_attributes: Option<&MutableNodeAttributes>, sub_dirs_delta: i64, change_time: Option<Timestamp>, ) -> Result<(), Error>
Updates attributes for the directory.
Nb: The casefold
attribute is ignored here. It should be set/cleared via set_casefold()
.
Sourcepub async fn update_dir_attributes_internal<'a>(
&self,
transaction: &mut Transaction<'a>,
object_id: u64,
mutable_node_attributes: MutableAttributesInternal,
) -> Result<(), Error>
pub async fn update_dir_attributes_internal<'a>( &self, transaction: &mut Transaction<'a>, object_id: u64, mutable_node_attributes: MutableAttributesInternal, ) -> Result<(), Error>
Updates attributes set in mutable_node_attributes
. MutableAttributesInternal can be
extended but should never include wrapping_key_id. Useful for object store Directory
methods that only have access to a reference to a transaction.
pub async fn get_properties(&self) -> Result<ObjectProperties, Error>
pub async fn list_extended_attributes(&self) -> Result<Vec<Vec<u8>>, Error>
pub async fn get_extended_attribute( &self, name: Vec<u8>, ) -> Result<Vec<u8>, Error>
pub async fn set_extended_attribute( &self, name: Vec<u8>, value: Vec<u8>, mode: SetExtendedAttributeMode, ) -> Result<(), Error>
pub async fn remove_extended_attribute( &self, name: Vec<u8>, ) -> Result<(), Error>
Sourcepub async fn iter<'a, 'b>(
&self,
merger: &'a mut Merger<'b, ObjectKey, ObjectValue>,
) -> Result<DirectoryIterator<'a, 'b>, Error>
pub async fn iter<'a, 'b>( &self, merger: &'a mut Merger<'b, ObjectKey, ObjectValue>, ) -> Result<DirectoryIterator<'a, 'b>, Error>
Returns an iterator that will return directory entries skipping deleted ones. Example usage:
let layer_set = dir.store().tree().layer_set(); let mut merger = layer_set.merger(); let mut iter = dir.iter(&mut merger).await?;
Sourcepub async fn iter_from<'a, 'b>(
&self,
merger: &'a mut Merger<'b, ObjectKey, ObjectValue>,
from: &str,
) -> Result<DirectoryIterator<'a, 'b>, Error>
pub async fn iter_from<'a, 'b>( &self, merger: &'a mut Merger<'b, ObjectKey, ObjectValue>, from: &str, ) -> Result<DirectoryIterator<'a, 'b>, Error>
Like “iter”, but seeks from a specific filename (inclusive). Example usage:
let layer_set = dir.store().tree().layer_set(); let mut merger = layer_set.merger(); let mut iter = dir.iter_from(&mut merger, “foo”).await?;
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for Directory<S>
impl<S> !RefUnwindSafe for Directory<S>
impl<S> Send for Directory<S>
impl<S> Sync for Directory<S>
impl<S> Unpin for Directory<S>
impl<S> UnwindSafe for Directory<S>where
S: RefUnwindSafe,
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, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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