pub struct Writer { /* private fields */ }
Expand description

A reference to an open file writing to the cache.

Implementations

Creates a new writable file handle into the cache.

Example
use async_attributes;
use async_std::prelude::*;

#[async_attributes::main]
async fn main() -> cacache::Result<()> {
    let mut fd = cacache::Writer::create("./my-cache", "my-key").await?;
    fd.write_all(b"hello world").await.expect("Failed to write to cache");
    // Data is not saved into the cache until you commit it.
    fd.commit().await?;
    Ok(())
}

Closes the Writer handle and writes content and index entries. Also verifies data against size and integrity options, if provided. Must be called manually in order to complete the writing process, otherwise everything will be thrown out.

Trait Implementations

Attempt to write bytes from buf into the object. Read more

Attempt to flush the object, ensuring that any buffered data reach their destination. Read more

Attempt to close the object. Read more

Attempt to write bytes from bufs into the object using vectored IO operations. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Writes some bytes into the byte stream. Read more

Like [write()][AsyncWriteExt::write()], except that it writes a slice of buffers. Read more

Writes an entire buffer into the byte stream. Read more

Flushes the stream to ensure that all buffered contents reach their destination. Read more

Closes the writer. Read more

Boxes the writer and changes its type to dyn AsyncWrite + Send + 'a. Read more

Creates a future which will entirely flush this AsyncWrite. Read more

Creates a future which will entirely close this AsyncWrite.

Creates a future which will write bytes from buf into the object. Read more

Creates a future which will write bytes from bufs into the object using vectored IO operations. Read more

Write data into this object. Read more

Allow using an [AsyncWrite] as a Sink<Item: AsRef<[u8]>>. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Writes some bytes into the byte stream. Read more

Flushes the stream to ensure that all buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

Writes an entire buffer into the byte stream. Read more

Writes a formatted string into this writer, returning any error encountered. Read more