Rust

body

Module

[Body]: the bytes a device writes or reads, as a stream.

Contents

use utopia_storage::Body;
Rust
pub struct Body(Box<dyn Source>)

The contents of a file, as a stream: what Device::write and the other writes take, and what Device::read returns.

A body is in memory (Body::from bytes), an open file (Body::from_file), any reader (Body::from_reader, read once) or a Source of your own. Writes on a seekable body start from its beginning; S3 needs a seekable one, as it hashes the body before sending it.

Rust
use utopia_storage::Body;

let body = Body::from("Hello World");
assert_eq!(&body.bytes().await?[..], b"Hello World");
Also implements Debug, From.
use utopia_storage::Source;
Rust
pub trait Source: Send

Where a Body reads its bytes from. Implement it to stream from a source of your own.

Implemented byMemoryFileAsyncFileReaderSpoolIncoming