Struct Directory

Source
pub struct Directory<S: HandleOwner> { /* private fields */ }
Expand description

A directory stores name to child object mappings.

Implementations§

Source§

impl<S: HandleOwner> Directory<S>

Source

pub fn object_id(&self) -> u64

Source

pub fn wrapping_key_id(&self) -> Option<u128>

Source

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.

Source

pub fn owner(&self) -> &Arc<S>

Source

pub fn store(&self) -> &ObjectStore

Source

pub fn handle(&self) -> &StoreObjectHandle<S>

Source

pub fn is_deleted(&self) -> bool

Source

pub fn set_deleted(&self)

Source

pub fn casefold(&self) -> bool

True if this directory is using casefolding (case-insensitive, normalized unicode filenames)

Source

pub async fn set_casefold(&self, val: bool) -> Result<(), Error>

Enables/disables casefolding. This can only be done on an empty directory.

Source

pub async fn create( transaction: &mut Transaction<'_>, owner: &Arc<S>, wrapping_key_id: Option<u128>, ) -> Result<Directory<S>, Error>

Source

pub async fn create_with_options( transaction: &mut Transaction<'_>, owner: &Arc<S>, wrapping_key_id: Option<u128>, casefold: bool, ) -> Result<Directory<S>, Error>

Source

pub async fn set_wrapping_key( &self, transaction: &mut Transaction<'_>, id: u128, ) -> Result<Cipher, Error>

Source

pub async fn open(owner: &Arc<S>, object_id: u64) -> Result<Directory<S>, Error>

Source

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.

Source

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.

Source

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.

Source

pub async fn create_child_dir( &self, transaction: &mut Transaction<'_>, name: &str, ) -> Result<Directory<S>, Error>

Source

pub async fn add_child_file<'a>( &self, transaction: &mut Transaction<'a>, name: &str, handle: &DataObjectHandle<S>, ) -> Result<(), Error>

Source

pub async fn create_child_file<'a>( &self, transaction: &mut Transaction<'a>, name: &str, ) -> Result<DataObjectHandle<S>, Error>

Source

pub async fn create_child_file_with_options<'a>( &self, transaction: &mut Transaction<'a>, name: &str, options: HandleOptions, ) -> Result<DataObjectHandle<S>, Error>

Source

pub async fn create_child_unnamed_temporary_file<'a>( &self, transaction: &mut Transaction<'a>, ) -> Result<DataObjectHandle<S>, Error>

Source

pub async fn add_child_volume( &self, transaction: &mut Transaction<'_>, volume_name: &str, store_object_id: u64, ) -> Result<(), Error>

Source

pub async fn delete_child_volume<'a>( &self, transaction: &mut Transaction<'a>, volume_name: &str, store_object_id: u64, ) -> Result<(), Error>

Source

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

Source

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().

Source

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.

Source

pub async fn get_properties(&self) -> Result<ObjectProperties, Error>

Source

pub async fn list_extended_attributes(&self) -> Result<Vec<Vec<u8>>, Error>

Source

pub async fn get_extended_attribute( &self, name: Vec<u8>, ) -> Result<Vec<u8>, Error>

Source

pub async fn set_extended_attribute( &self, name: Vec<u8>, value: Vec<u8>, mode: SetExtendedAttributeMode, ) -> Result<(), Error>

Source

pub async fn remove_extended_attribute( &self, name: Vec<u8>, ) -> Result<(), Error>

Source

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?;

Source

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§

Source§

impl<S: HandleOwner> Debug for Directory<S>

Source§

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

Formats the value using the given formatter. Read more

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> 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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

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