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>
impl<'data, 'dir> ScopedDir<'data, 'dir>
Sourcepub fn dir<'dir2>(&'dir2 self, name: &CStr) -> ScopedDir<'data, 'dir2>
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.
Sourcepub fn read_only_file<T: Writer + Send + Sync + 'static>(
&self,
name: &CStr,
data: &'data T,
)
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.
Sourcepub fn read_callback_file<T, F>(
&self,
name: &CStr,
data: &'data T,
_f: &'static F,
)
pub fn read_callback_file<T, F>( &self, name: &CStr, data: &'data T, _f: &'static F, )
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.
Sourcepub fn read_write_file<T: Writer + Reader + Send + Sync + 'static>(
&self,
name: &CStr,
data: &'data T,
)
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.
Sourcepub fn read_write_callback_file<T, F, W>(
&self,
name: &CStr,
data: &'data T,
_f: &'static F,
_w: &'static W,
)
pub fn read_write_callback_file<T, F, W>( &self, name: &CStr, data: &'data T, _f: &'static F, _w: &'static W, )
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.
Sourcepub fn write_only_file<T: Reader + Send + Sync + 'static>(
&self,
name: &CStr,
data: &'data T,
)
pub fn write_only_file<T: Reader + Send + Sync + 'static>( &self, name: &CStr, data: &'data T, )
Sourcepub fn write_only_callback_file<T, W>(
&self,
name: &CStr,
data: &'data T,
_w: &'static W,
)
pub fn write_only_callback_file<T, W>( &self, name: &CStr, data: &'data T, _w: &'static W, )
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> 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> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot
. Read more