Skip to main content

Content

Trait Content 

Source
pub trait Content {
    // Required methods
    fn metadata(&self) -> ContentMetadata;
    fn open(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Rc<dyn ContentReader>, ContentError>> + '_>>;

    // Provided method
    fn read_all(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ContentError>> + '_>> { ... }
}
Expand description

One readable piece of content from any source.

Required Methods§

Source

fn metadata(&self) -> ContentMetadata

What the provider states about this content without reading it.

Source

fn open( &self, ) -> Pin<Box<dyn Future<Output = Result<Rc<dyn ContentReader>, ContentError>> + '_>>

Opens a chunked reader over the bytes.

Provided Methods§

Source

fn read_all( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ContentError>> + '_>>

Reads every byte. The default drains open; providers already holding the bytes override it to avoid the copy.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§