Skip to main content

FileWriter

Trait FileWriter 

Source
pub trait FileWriter: Send {
    // Required methods
    fn write<B: IoBuf>(
        &mut self,
        buffer: B,
        cancellation: &Cancellation,
    ) -> impl Future<Output = BufferResult<B>> + Send;
    fn write_at<B: IoBuf>(
        &mut self,
        buffer: B,
        offset: u64,
        cancellation: &Cancellation,
    ) -> impl Future<Output = BufferResult<B>> + Send;
    fn close(&mut self) -> impl Future<Output = Result<()>> + Send;

    // Provided methods
    fn write_all<B: IoBuf>(
        &mut self,
        buffer: B,
        cancellation: &Cancellation,
    ) -> impl Future<Output = BufferResult<B>> + Send { ... }
    fn write_submit<B: IoBuf>(
        &mut self,
        buffer: B,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<impl Future<Output = BufferResult<B>> + Send + 'static, (OperationError, B)>> + Send { ... }
    fn write_at_submit<B: IoBuf>(
        &mut self,
        buffer: B,
        offset: u64,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<impl Future<Output = BufferResult<B>> + Send + 'static, (OperationError, B)>> + Send { ... }
}
Expand description

Scheduler-bound, sequential access to a file’s writable direction. Construct through FileWriting. Operations preserve the file’s shared OS cursor; separate handles do not coordinate writes through aliases.

Required Methods§

Source

fn write<B: IoBuf>( &mut self, buffer: B, cancellation: &Cancellation, ) -> impl Future<Output = BufferResult<B>> + Send

Write once at the shared cursor, returning a possibly short count and the original owner on every result. Success does not imply durability; cancellation cannot roll back a transferred prefix.

Source

fn write_at<B: IoBuf>( &mut self, buffer: B, offset: u64, cancellation: &Cancellation, ) -> impl Future<Output = BufferResult<B>> + Send

Write once at an explicit offset, requiring the offset to fit in i64. Unix implementations leave the shared cursor unchanged; Windows implementations may use seek_write, which changes it. The handle maintains no private cursor.

Source

fn close(&mut self) -> impl Future<Output = Result<()>> + Send

Stop admission and await accepted operation retirement without cancellation. Repeated close is safe; dropping a pending close is not a retirement barrier. This does not synchronize or close the underlying file. Drop the retired handle before exclusive file close.

Provided Methods§

Source

fn write_all<B: IoBuf>( &mut self, buffer: B, cancellation: &Cancellation, ) -> impl Future<Output = BufferResult<B>> + Send

Write the entire initialized range in order, returning its length and original owner. Partial writes advance an owned view without copying. A nonempty zero-progress write is WriteZero; failure may follow a transferred prefix.

Source

fn write_submit<B: IoBuf>( &mut self, buffer: B, cancellation: &Cancellation, ) -> impl Future<Output = Result<impl Future<Output = BufferResult<B>> + Send + 'static, (OperationError, B)>> + Send

Await admission separately from collecting the original owner. Accepted work can complete independently of polling the returned future. The fallback completes the ordinary operation before returning; backends can admit independently progressing work earlier. Pre-cancellation rejects admission and returns the unchanged owner.

Source

fn write_at_submit<B: IoBuf>( &mut self, buffer: B, offset: u64, cancellation: &Cancellation, ) -> impl Future<Output = Result<impl Future<Output = BufferResult<B>> + Send + 'static, (OperationError, B)>> + Send

Await admission separately from collecting the original owner. Accepted work can complete independently of polling the returned future. The fallback completes the ordinary operation before returning; backends can admit independently progressing work earlier. Pre-cancellation rejects admission and returns the unchanged owner.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§