Struct ScopedDir

Source
pub struct ScopedDir<'data, 'dir> { /* private fields */ }
Expand description

A handle to a directory which will live at most 'dir, accessing data that will live for at least 'data.

Dropping a ScopedDir will not delete or clean it up, this is expected to occur through dropping the Scope that created it.

Implementations§

Source§

impl<'data, 'dir> ScopedDir<'data, 'dir>

Source

pub fn dir<'dir2>(&'dir2 self, name: &CStr) -> ScopedDir<'data, 'dir2>

Creates a subdirectory inside this ScopedDir.

The returned directory handle cannot outlive this one.

Source

pub fn read_only_file<T: Writer + Send + Sync + 'static>( &self, name: &CStr, data: &'data T, )

Creates a read-only file in this directory.

The file’s contents are produced by invoking Writer::write.

This function does not produce an owning handle to the file. The created file is removed when the Scope that this directory belongs to is dropped.

Source

pub fn read_callback_file<T, F>( &self, name: &CStr, data: &'data T, _f: &'static F, )
where T: Send + Sync + 'static, F: Fn(&T, &mut Formatter<'_>) -> Result + Send + Sync,

Creates a read-only file in this directory, with contents from a callback.

The file contents are generated by calling f with data.

f must be a function item or a non-capturing closure. This is statically asserted and not a safety requirement.

This function does not produce an owning handle to the file. The created file is removed when the Scope that this directory belongs to is dropped.

Source

pub fn read_write_file<T: Writer + Reader + Send + Sync + 'static>( &self, name: &CStr, data: &'data T, )

Creates a read-write file in this directory.

Reading the file uses the Writer implementation on data. Writing to the file uses the Reader implementation on data.

This function does not produce an owning handle to the file. The created file is removed when the Scope that this directory belongs to is dropped.

Source

pub fn read_write_callback_file<T, F, W>( &self, name: &CStr, data: &'data T, _f: &'static F, _w: &'static W, )
where T: Send + Sync + 'static, F: Fn(&T, &mut Formatter<'_>) -> Result + Send + Sync, W: Fn(&T, &mut UserSliceReader) -> Result + Send + Sync,

Creates a read-write file in this directory, with logic from callbacks.

Reading from the file is handled by f. Writing to the file is handled by w.

f and w must be function items or non-capturing closures. This is statically asserted and not a safety requirement.

This function does not produce an owning handle to the file. The created file is removed when the Scope that this directory belongs to is dropped.

Source

pub fn write_only_file<T: Reader + Send + Sync + 'static>( &self, name: &CStr, data: &'data T, )

Creates a write-only file in this directory.

Writing to the file uses the Reader implementation on data.

This function does not produce an owning handle to the file. The created file is removed when the Scope that this directory belongs to is dropped.

Source

pub fn write_only_callback_file<T, W>( &self, name: &CStr, data: &'data T, _w: &'static W, )
where T: Send + Sync + 'static, W: Fn(&T, &mut UserSliceReader) -> Result + Send + Sync,

Creates a write-only file in this directory, with write logic from a callback.

Writing to the file is handled by w.

w must be a function item or a non-capturing closure. This is statically asserted and not a safety requirement.

This function does not produce an owning handle to the file. The created file is removed when the Scope that this directory belongs to is dropped.

Auto Trait Implementations§

§

impl<'data, 'dir> Freeze for ScopedDir<'data, 'dir>

§

impl<'data, 'dir> !RefUnwindSafe for ScopedDir<'data, 'dir>

§

impl<'data, 'dir> Send for ScopedDir<'data, 'dir>

§

impl<'data, 'dir> Sync for ScopedDir<'data, 'dir>

§

impl<'data, 'dir> Unpin for ScopedDir<'data, 'dir>

§

impl<'data, 'dir> !UnwindSafe for ScopedDir<'data, 'dir>

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

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. 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> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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.