Skip to main content

Host

Trait Host 

Source
pub trait Host {
    // Required methods
    fn read_classified(
        &self,
        label: &str,
        max: usize,
    ) -> Result<Option<Vec<u8>>, ReadFail>;
    fn ensure_absent(&self, label: &str) -> Result<(), IoFail>;
    fn create(&self, label: &str, bytes: &[u8]) -> Result<(), IoFail>;
    fn write_all(&self, files: &[(String, Vec<u8>)]) -> Result<(), IoFail>;
    fn join(&self, dir: &str, name: &str) -> String;

    // Provided methods
    fn read(&self, label: &str, limit: usize) -> Result<Vec<u8>, IoFail> { ... }
    fn read_bounded(
        &self,
        label: &str,
        max: usize,
    ) -> Result<Option<Vec<u8>>, IoFail> { ... }
}
Expand description

The host of one command.

Required Methods§

Source

fn read_classified( &self, label: &str, max: usize, ) -> Result<Option<Vec<u8>>, ReadFail>

Read label, at most max bytes of it; None when it does not exist. A failure of the input is told from an exhausted command budget, which depends on read order rather than on the input.

Source

fn ensure_absent(&self, label: &str) -> Result<(), IoFail>

Refuse an output that already exists, before any work. A pure check that changes nothing, so calling it again for the same label gives the same answer: commands check every output up front and again just before writing.

Source

fn create(&self, label: &str, bytes: &[u8]) -> Result<(), IoFail>

Publish one output, never overwriting.

Source

fn write_all(&self, files: &[(String, Vec<u8>)]) -> Result<(), IoFail>

Publish every (label, bytes), all or none.

Source

fn join(&self, dir: &str, name: &str) -> String

The label of name inside the output or input directory dir.

Provided Methods§

Source

fn read(&self, label: &str, limit: usize) -> Result<Vec<u8>, IoFail>

Read label up to its document limit plus one byte, so an oversized input reaches the parser and is refused by the document’s own bound.

Source

fn read_bounded( &self, label: &str, max: usize, ) -> Result<Option<Vec<u8>>, IoFail>

Like Host::read with an explicit maximum, returning None for an input that does not exist.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§