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
impl FileWriter
Sourcepub async fn write_from<R: AsyncRead + Unpin>(
self,
reader: &mut R,
written: impl FnMut(&[u8]),
batch: &mut FlushBatch,
) -> Result<(), FileError>
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.
Sourcepub async fn append(&mut self, bytes: &[u8]) -> Result<(), FileError>
pub async fn append(&mut self, bytes: &[u8]) -> Result<(), FileError>
Append one bounded buffer, completing its disk write before returning.
Sourcepub async fn finish(self) -> Result<(), FileError>
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.
Sourcepub async fn sync(&mut self) -> Result<(), FileError>
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.
Sourcepub async fn finish_into(self, batch: &mut FlushBatch) -> Result<(), FileError>
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.