pub trait Resource: Debug + ToString {
    // Required methods
    fn get_mime_type(&self) -> String;
    fn sub(&self, s: &str, mime_type: &str) -> Result<Box<dyn Resource>, Error>;
    fn open(&self) -> Result<Box<dyn Read>, Error>;

    // Provided method
    fn read_to_memory(&self) -> Result<Vec<u8>, Error> { ... }
}
Expand description

A resource is a descriptor to a specific resource, e.g., a filepath ot a URL. It is possible to create sub-resources from a resource, e.g., ‘../foobar.txt’.

Required Methods§

source

fn get_mime_type(&self) -> String

Returns the mimetype of the current resource.

source

fn sub(&self, s: &str, mime_type: &str) -> Result<Box<dyn Resource>, Error>

Creates a new resource to the specified sub-resource.

Arguments
  • s - The string which specified the sub-resource. E.g., for filepaths this could be ‘../foobar.txt’.
  • mime_type - The mime type of the new sub resource.
source

fn open(&self) -> Result<Box<dyn Read>, Error>

Tries to open a reader to the currently specified resource.

Provided Methods§

source

fn read_to_memory(&self) -> Result<Vec<u8>, Error>

Opens a reader to the specified resource and copies the content to an U8 buffer.

Implementors§