Skip to main content

FileWriter

Struct FileWriter 

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

An unpublished file’s open writer. Its OS handle and path stay private. Dropping it leaves the named bytes for the caller’s recorded cleanup. The shared store lock lasts until its handle and any cancelled I/O finish, and, for a file finished into a batch, until the batch’s flush ends.

Implementations§

Source§

impl FileWriter

Source

pub async fn write_from<R: AsyncRead + Unpin>( self, reader: &mut R, written: impl FnMut(&[u8]), batch: &mut FlushBatch, ) -> Result<(), FileError>

Read once in 64 KiB chunks, reporting each chunk after its disk write, then finish the file into batch.

Source

pub async fn append(&mut self, bytes: &[u8]) -> Result<(), FileError>

Append one bounded buffer, completing its disk write before returning.

Source

pub async fn finish(self) -> Result<(), FileError>

Sync all appended bytes, then flush their directory and the drive’s cache, as a batch of this one file, before publishing metadata.

Source

pub async fn sync(&mut self) -> Result<(), FileError>

Sync all appended bytes and flush their directory and the drive’s cache, keeping the writer open: what was appended before is durable when this returns.

Source

pub async fn finish_into(self, batch: &mut FlushBatch) -> Result<(), FileError>

Sync all appended bytes and count the file in batch, whose flush makes it durable before the commit that records it.

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 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, 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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,