Skip to main content

AsyncTempFile

Struct AsyncTempFile 

Source
pub struct AsyncTempFile { /* private fields */ }
Expand description

A facade-owned asynchronous temporary file.

§Examples

This example uses an isolated in-memory provider fixture.

use qubit_fs::temp::TempOptions;
use qubit_fs::temp::TempResourceState;

let mut temporary = filesystem.create_temp_file(TempOptions::default()).await?;
temporary.cleanup().await?;
assert_eq!(TempResourceState::Cleaned, temporary.state());

Implementations§

Source§

impl AsyncTempFile

Source

pub const fn path(&self) -> &Path

Returns the provider-local temporary path.

§Returns

The validated path supplied by the provider.

Source

pub const fn state(&self) -> TempResourceState

Returns the current ownership lifecycle state.

§Returns

The handle’s current cleanup and publication state.

Source

pub fn child(&self, component: &PathComponent) -> Path

Returns one lexically safe child path.

Source

pub fn descendant(&self, relative: &RelativePath) -> Path

Returns one lexically safe descendant path.

Source

pub fn cleanup(&mut self) -> SpiFuture<'_, FsResult<()>>

Asynchronously confirms cleanup of this temporary resource.

§Returns

A future resolving after provider cleanup is confirmed.

§Errors

Resolves to an invalid-state error when cleanup is no longer legal, or to the provider cleanup failure.

Source

pub fn keep(&mut self) -> SpiFuture<'_, Result<PersistOutcome, PersistFailure>>

Asynchronously publishes this temporary resource to a generated target.

§Returns

A future resolving to the provider’s confirmed publication outcome.

§Errors

Resolves to an invalid-state error when the resource is no longer owned, or to the provider ownership-transfer failure. An invalid-state failure retains any previously confirmed publication target and recovery state.

Source

pub fn persist<'a>( &'a mut self, target: &'a Path, options: PersistOptions, ) -> SpiFuture<'a, Result<PersistOutcome, PersistFailure>>

Asynchronously persists this resource to a validated destination.

§Parameters
  • target: Validated destination path.
  • options: Persistence atomicity and publication requirements.
  • options: Persistence atomicity and publication requirements.
§Returns

A future resolving to the confirmed persistence outcome.

§Errors

Resolves to a typed failure for invalid lifecycle state, failed local preflight, provider failure, or provider contract violation. Rejected repeated calls preserve the previously confirmed publication facts.

Trait Implementations§

Source§

impl Drop for AsyncTempFile

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.